Commit f942dabe authored by hongguangwu's avatar hongguangwu

Merge remote-tracking branch 'origin/develop' into develop

parents 1f0a60ad 05ea5991
...@@ -22,7 +22,8 @@ import io.swagger.v3.oas.annotations.media.Schema; ...@@ -22,7 +22,8 @@ import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.time.LocalDate; import javax.validation.constraints.Max;
import java.util.Date;
/** /**
* 员工学历信息表 * 员工学历信息表
...@@ -46,12 +47,14 @@ public class TEmpEducation extends BaseEntity { ...@@ -46,12 +47,14 @@ public class TEmpEducation extends BaseEntity {
/** /**
* 员工ID * 员工ID
*/ */
@Max(value = 20)
@Schema(description = "员工ID") @Schema(description = "员工ID")
private String empId; private String empId;
/** /**
* 员工姓名 * 员工姓名
*/ */
@Max(value = 20)
@Schema(description = "员工姓名") @Schema(description = "员工姓名")
private String empName; private String empName;
...@@ -64,6 +67,7 @@ public class TEmpEducation extends BaseEntity { ...@@ -64,6 +67,7 @@ public class TEmpEducation extends BaseEntity {
/** /**
* 身份证号 * 身份证号
*/ */
@Max(value = 20)
@Schema(description = "身份证号") @Schema(description = "身份证号")
private String empIdcard; private String empIdcard;
...@@ -71,11 +75,12 @@ public class TEmpEducation extends BaseEntity { ...@@ -71,11 +75,12 @@ public class TEmpEducation extends BaseEntity {
* 入学时间 * 入学时间
*/ */
@Schema(description = "入学时间") @Schema(description = "入学时间")
private LocalDate entryDate; private Date entryDate;
/** /**
* 学历名称 * 学历名称
*/ */
@Max(value = 50)
@Schema(description = "学历名称") @Schema(description = "学历名称")
private String educationName; private String educationName;
...@@ -83,11 +88,12 @@ public class TEmpEducation extends BaseEntity { ...@@ -83,11 +88,12 @@ public class TEmpEducation extends BaseEntity {
* 结业日期 * 结业日期
*/ */
@Schema(description = "结业日期") @Schema(description = "结业日期")
private LocalDate gradutionDate; private Date gradutionDate;
/** /**
* 学校名称 * 学校名称
*/ */
@Max(value = 50)
@Schema(description = "学校名称") @Schema(description = "学校名称")
private String school; private String school;
...@@ -112,6 +118,7 @@ public class TEmpEducation extends BaseEntity { ...@@ -112,6 +118,7 @@ public class TEmpEducation extends BaseEntity {
/** /**
* 院系名称 * 院系名称
*/ */
@Max(value = 50)
@Schema(description = "院系名称") @Schema(description = "院系名称")
private String collageSystem; private String collageSystem;
...@@ -131,18 +138,21 @@ public class TEmpEducation extends BaseEntity { ...@@ -131,18 +138,21 @@ public class TEmpEducation extends BaseEntity {
/** /**
* 证书名称 * 证书名称
*/ */
@Max(value = 50)
@Schema(description = "证书名称") @Schema(description = "证书名称")
private String certificationName; private String certificationName;
/** /**
* 备注 * 备注
*/ */
@Max(value = 200)
@Schema(description = "备注") @Schema(description = "备注")
private String remark; private String remark;
/** /**
* 专业 * 专业
*/ */
@Max(value = 50)
@Schema(description = "专业") @Schema(description = "专业")
private String major; private String major;
......
...@@ -30,6 +30,7 @@ import javax.validation.constraints.NotNull; ...@@ -30,6 +30,7 @@ import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
...@@ -217,13 +218,13 @@ public class TEmployeeInfo extends BaseEntity { ...@@ -217,13 +218,13 @@ public class TEmployeeInfo extends BaseEntity {
* 入学时间 * 入学时间
*/ */
@Schema(description = "入学时间") @Schema(description = "入学时间")
private LocalDate admissionDate; private Date admissionDate;
/** /**
* 毕业时间 * 毕业时间
*/ */
@Schema(description = "毕业时间") @Schema(description = "毕业时间")
private LocalDate gradutionDate; private Date gradutionDate;
/** /**
* 备注 * 备注
......
package com.yifu.cloud.plus.v1.yifu.archives.vo; package com.yifu.cloud.plus.v1.yifu.archives.vo;
import cn.hutool.core.date.DateTime;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpProfessionalQualification; import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpProfessionalQualification;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
......
package com.yifu.cloud.plus.v1.yifu.archives.vo; package com.yifu.cloud.plus.v1.yifu.archives.vo;
import cn.hutool.core.date.DateTime;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpDisabilityInfo; import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpDisabilityInfo;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
......
package com.yifu.cloud.plus.v1.yifu.archives.vo; package com.yifu.cloud.plus.v1.yifu.archives.vo;
import cn.hutool.core.date.DateTime;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpEducation; import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpEducation;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
......
...@@ -26,7 +26,7 @@ public class EmpDisabilityExcelVO extends RowIndex implements Serializable { ...@@ -26,7 +26,7 @@ public class EmpDisabilityExcelVO extends RowIndex implements Serializable {
/** /**
* 员工姓名 * 员工姓名
*/ */
@ExcelAttribute(name = "员工姓名",errorInfo = "员工姓名不可为空",maxLength = 20) @ExcelAttribute(name = "员工姓名",isNotEmpty = true, errorInfo = "员工姓名不可为空",maxLength = 20)
@NotNull(message = "员工姓名不能为空") @NotNull(message = "员工姓名不能为空")
@ExcelProperty(value ="员工姓名") @ExcelProperty(value ="员工姓名")
private String empName; private String empName;
...@@ -34,7 +34,7 @@ public class EmpDisabilityExcelVO extends RowIndex implements Serializable { ...@@ -34,7 +34,7 @@ public class EmpDisabilityExcelVO extends RowIndex implements Serializable {
/** /**
* 员工身份证 * 员工身份证
*/ */
@ExcelAttribute(name = "身份证号",errorInfo = "员工身份证不能为空",maxLength = 20) @ExcelAttribute(name = "身份证号",isNotEmpty = true, errorInfo = "员工身份证不能为空",maxLength = 20)
@NotNull(message = "员工身份证不能为空") @NotNull(message = "员工身份证不能为空")
@ExcelProperty(value ="身份证号") @ExcelProperty(value ="身份证号")
private String empIdcard; private String empIdcard;
...@@ -42,7 +42,7 @@ public class EmpDisabilityExcelVO extends RowIndex implements Serializable { ...@@ -42,7 +42,7 @@ public class EmpDisabilityExcelVO extends RowIndex implements Serializable {
/** /**
* 伤残病名称 * 伤残病名称
*/ */
@ExcelAttribute(name = "伤残病名称",errorInfo = "伤残病名称不能为空",maxLength = 50) @ExcelAttribute(name = "伤残病名称",isNotEmpty = true, errorInfo = "伤残病名称不能为空",maxLength = 50)
@NotNull(message = "伤残病名称不能为空") @NotNull(message = "伤残病名称不能为空")
@ExcelProperty(value ="伤残病名称") @ExcelProperty(value ="伤残病名称")
private String disabilityName; private String disabilityName;
...@@ -57,7 +57,7 @@ public class EmpDisabilityExcelVO extends RowIndex implements Serializable { ...@@ -57,7 +57,7 @@ public class EmpDisabilityExcelVO extends RowIndex implements Serializable {
/** /**
* 伤残等级 * 伤残等级
*/ */
@ExcelAttribute(name = "伤残等级",errorInfo = "伤残等级不能为空",isDataId = true, dataType = "disability_grade") @ExcelAttribute(name = "伤残等级",isNotEmpty = true, errorInfo = "伤残等级不能为空",isDataId = true, dataType = "disability_grade")
@NotNull(message = "伤残等级不能为空") @NotNull(message = "伤残等级不能为空")
@ExcelProperty(value ="伤残等级") @ExcelProperty(value ="伤残等级")
private String disabilityLevel; private String disabilityLevel;
...@@ -65,7 +65,7 @@ public class EmpDisabilityExcelVO extends RowIndex implements Serializable { ...@@ -65,7 +65,7 @@ public class EmpDisabilityExcelVO extends RowIndex implements Serializable {
/** /**
* 伤残开始日期 * 伤残开始日期
*/ */
@ExcelAttribute(name = "伤残开始日期",errorInfo = "伤残开始日期不能为空",isDate = true) @ExcelAttribute(name = "伤残开始日期",isNotEmpty = true, errorInfo = "伤残开始日期不能为空",isDate = true)
@NotNull(message = "伤残开始日期不能为空") @NotNull(message = "伤残开始日期不能为空")
@Past @Past
@DateTimeFormat("YYYY-MM-dd") @DateTimeFormat("YYYY-MM-dd")
...@@ -75,7 +75,7 @@ public class EmpDisabilityExcelVO extends RowIndex implements Serializable { ...@@ -75,7 +75,7 @@ public class EmpDisabilityExcelVO extends RowIndex implements Serializable {
/** /**
* 伤残结束日期 * 伤残结束日期
*/ */
@ExcelAttribute(name = "伤残结束日期",errorInfo = "伤残结束日期不能为空",isDate = true) @ExcelAttribute(name = "伤残结束日期",isNotEmpty = true, errorInfo = "伤残结束日期不能为空",isDate = true)
@NotNull(message = "伤残结束日期不能为空") @NotNull(message = "伤残结束日期不能为空")
@Past @Past
@DateTimeFormat("YYYY-MM-dd") @DateTimeFormat("YYYY-MM-dd")
...@@ -85,7 +85,7 @@ public class EmpDisabilityExcelVO extends RowIndex implements Serializable { ...@@ -85,7 +85,7 @@ public class EmpDisabilityExcelVO extends RowIndex implements Serializable {
/** /**
* 是否工伤标识0是/1否 * 是否工伤标识0是/1否
*/ */
@ExcelAttribute(name = "是否工伤",errorInfo = "是否工伤不可为空",readConverterExp = "0:是,1:否") @ExcelAttribute(name = "是否工伤",isNotEmpty = true, errorInfo = "是否工伤不可为空",readConverterExp = "0=是,1=否")
@NotNull(message = "是否工伤标识(0是/1否)不能为空") @NotNull(message = "是否工伤标识(0是/1否)不能为空")
@ExcelProperty(value ="是否工伤") @ExcelProperty(value ="是否工伤")
private String injuryIdentification; private String injuryIdentification;
......
...@@ -79,7 +79,7 @@ public class EmpEducationExcelVO extends RowIndex implements Serializable { ...@@ -79,7 +79,7 @@ public class EmpEducationExcelVO extends RowIndex implements Serializable {
/** /**
* 最高学历标识0是/1否 * 最高学历标识0是/1否
*/ */
@ExcelAttribute(name = "最高学历",errorInfo = "最高学历不可为空",readConverterExp = "是:0,否:1") @ExcelAttribute(name = "最高学历",errorInfo = "最高学历不可为空",readConverterExp = "0=是,1=否")
@NotNull(message = "最高学历标识不可为空") @NotNull(message = "最高学历标识不可为空")
@ExcelProperty(value ="最高学历") @ExcelProperty(value ="最高学历")
private String highIdentification; private String highIdentification;
......
...@@ -20,15 +20,15 @@ public class EmpEducationUpdateExcelVo extends RowIndex{ ...@@ -20,15 +20,15 @@ public class EmpEducationUpdateExcelVo extends RowIndex{
* @Author fxj * @Author fxj
* @Description 主键 * @Description 主键
**/ **/
@ExcelAttribute(name = "主键",errorInfo = "主键不可为空") @ExcelAttribute(name = "唯一标识", isNotEmpty = true,errorInfo = "唯一标识不可为空")
@NotNull(message = "主键不可为空") @NotNull(message = "唯一标识不可为空")
@ExcelProperty(value ="主键") @ExcelProperty(value ="唯一标识")
private String id; private String id;
/** /**
* 学校名称 * 学校名称
*/ */
@ExcelAttribute(name = "学校",errorInfo = "学校不可为空") @ExcelAttribute(name = "学校", isNotEmpty = true,errorInfo = "学校不可为空")
@NotNull(message = "学校不可为空") @NotNull(message = "学校不可为空")
@ExcelProperty(value ="学校") @ExcelProperty(value ="学校")
private String school; private String school;
...@@ -44,7 +44,7 @@ public class EmpEducationUpdateExcelVo extends RowIndex{ ...@@ -44,7 +44,7 @@ public class EmpEducationUpdateExcelVo extends RowIndex{
/** /**
* 专业 * 专业
*/ */
@ExcelAttribute(name = "专业",errorInfo = "专业不可为空") @ExcelAttribute(name = "专业", isNotEmpty = true,errorInfo = "专业不可为空")
@NotNull(message = "专业不可为空") @NotNull(message = "专业不可为空")
@ExcelProperty(value ="专业") @ExcelProperty(value ="专业")
private String major; private String major;
...@@ -52,7 +52,7 @@ public class EmpEducationUpdateExcelVo extends RowIndex{ ...@@ -52,7 +52,7 @@ public class EmpEducationUpdateExcelVo extends RowIndex{
/** /**
* 学历名称 * 学历名称
*/ */
@ExcelAttribute(name = "学历",errorInfo = "学历不可为空") @ExcelAttribute(name = "学历", isNotEmpty = true,errorInfo = "学历不可为空", isDataId = true, dataType = "education")
@NotNull(message = "学历不可为空") @NotNull(message = "学历不可为空")
@ExcelProperty(value ="学历") @ExcelProperty(value ="学历")
private String educationName; private String educationName;
...@@ -60,14 +60,14 @@ public class EmpEducationUpdateExcelVo extends RowIndex{ ...@@ -60,14 +60,14 @@ public class EmpEducationUpdateExcelVo extends RowIndex{
/** /**
* 学历类型:全日制、自考、函授等 * 学历类型:全日制、自考、函授等
*/ */
@ExcelAttribute(name = "学历类型") @ExcelAttribute(name = "学历类型", isDataId = true, dataType = "education_type")
@ExcelProperty(value ="学历类型") @ExcelProperty(value ="学历类型")
private String type; private String type;
/** /**
* 最高学历标识0是/1否 * 最高学历标识0是/1否
*/ */
@ExcelAttribute(name = "最高学历",errorInfo = "最高学历标识不可为空",readConverterExp = "0:是,1:否") @ExcelAttribute(name = "最高学历", isNotEmpty = true,errorInfo = "最高学历标识不可为空",readConverterExp = "0=是,1=否")
@NotNull(message = "最高学历标识不可为空") @NotNull(message = "最高学历标识不可为空")
@ExcelProperty(value ="最高学历") @ExcelProperty(value ="最高学历")
private String highIdentification; private String highIdentification;
...@@ -75,25 +75,25 @@ public class EmpEducationUpdateExcelVo extends RowIndex{ ...@@ -75,25 +75,25 @@ public class EmpEducationUpdateExcelVo extends RowIndex{
/** /**
* 学制类型:四年、三年、五年、二年 * 学制类型:四年、三年、五年、二年
*/ */
@ExcelAttribute(name = "学制类型") @ExcelAttribute(name = "学制类型", isDataId = true, dataType = "education_system")
@ExcelProperty(value ="学制类型") @ExcelProperty(value ="学制类型")
private String educationSystem; private String educationSystem;
/** /**
* 入学时间 * 入学时间
*/ */
@ExcelAttribute(name = "入学时间",errorInfo = "入学时间不可为空",isDate = true) @ExcelAttribute(name = "入学时间", isNotEmpty = true,errorInfo = "入学时间不可为空",isDate = true)
@NotNull(message = "入学时间不可为空") @NotNull(message = "入学时间不可为空")
@DateTimeFormat("YYYY-MM-dd") @DateTimeFormat("yyyy-MM-dd")
@ExcelProperty(value ="入学时间") @ExcelProperty(value ="入学时间")
private Date entryDate; private Date entryDate;
/** /**
* 结业日期 * 结业日期
*/ */
@ExcelAttribute(name = "毕业时间",errorInfo = "毕业时间不可为空",isDate = true) @ExcelAttribute(name = "毕业时间", isNotEmpty = true,errorInfo = "毕业时间不可为空",isDate = true)
@NotNull(message = "毕业时间不可为空") @NotNull(message = "毕业时间不可为空")
@DateTimeFormat("YYYY-MM-dd") @DateTimeFormat("yyyy-MM-dd")
@ExcelProperty(value ="毕业时间") @ExcelProperty(value ="毕业时间")
private Date gradutionDate; private Date gradutionDate;
......
...@@ -25,14 +25,14 @@ public class EmpWorkRecordExcelVO extends RowIndex implements Serializable { ...@@ -25,14 +25,14 @@ public class EmpWorkRecordExcelVO extends RowIndex implements Serializable {
/** /**
* 员工姓名 * 员工姓名
*/ */
@ExcelAttribute(name = "员工姓名",errorInfo = "员工姓名不可为空",maxLength = 20) @ExcelAttribute(name = "员工姓名",isNotEmpty = true,errorInfo = "员工姓名不可为空",maxLength = 20)
@NotNull(message = "员工姓名不可为空") @NotNull(message = "员工姓名不可为空")
@ExcelProperty(value ="员工姓名") @ExcelProperty(value ="员工姓名")
private String empName; private String empName;
/** /**
* 员工身份证 * 员工身份证
*/ */
@ExcelAttribute(name = "身份证号",errorInfo = "员工身份证不可为空",maxLength = 20) @ExcelAttribute(name = "身份证号",isNotEmpty = true,errorInfo = "员工身份证不可为空",maxLength = 20)
@NotNull(message = "员工身份证不可为空") @NotNull(message = "员工身份证不可为空")
@ExcelProperty(value ="身份证号") @ExcelProperty(value ="身份证号")
private String empIdcard; private String empIdcard;
...@@ -40,7 +40,7 @@ public class EmpWorkRecordExcelVO extends RowIndex implements Serializable { ...@@ -40,7 +40,7 @@ public class EmpWorkRecordExcelVO extends RowIndex implements Serializable {
/** /**
* 工作单位 * 工作单位
*/ */
@ExcelAttribute(name = "工作单位",errorInfo = "工作单位不可为空",maxLength = 100) @ExcelAttribute(name = "工作单位",isNotEmpty = true,errorInfo = "工作单位不可为空",maxLength = 100)
@NotNull(message = "工作单位不可为空") @NotNull(message = "工作单位不可为空")
@ExcelProperty(value ="工作单位") @ExcelProperty(value ="工作单位")
private String workUnit; private String workUnit;
...@@ -48,7 +48,7 @@ public class EmpWorkRecordExcelVO extends RowIndex implements Serializable { ...@@ -48,7 +48,7 @@ public class EmpWorkRecordExcelVO extends RowIndex implements Serializable {
/** /**
* 工作部门 * 工作部门
*/ */
@ExcelAttribute(name = "工作部门",errorInfo = "工作部门不可为空",maxLength = 100) @ExcelAttribute(name = "工作部门",isNotEmpty = true,errorInfo = "工作部门不可为空",maxLength = 100)
@NotNull(message = "工作部门不可为空") @NotNull(message = "工作部门不可为空")
@ExcelProperty(value ="工作部门") @ExcelProperty(value ="工作部门")
private String workDepart; private String workDepart;
...@@ -70,7 +70,7 @@ public class EmpWorkRecordExcelVO extends RowIndex implements Serializable { ...@@ -70,7 +70,7 @@ public class EmpWorkRecordExcelVO extends RowIndex implements Serializable {
/** /**
* 是否在岗:0是/1否 * 是否在岗:0是/1否
*/ */
@ExcelAttribute(name = "在职状态",errorInfo = "在职状态不可为空",isDataId = true,readConverterExp = "0:是,1:否") @ExcelAttribute(name = "在职状态",isNotEmpty = true,errorInfo = "在职状态不可为空",isDataId = true,readConverterExp = "0=在职,1=离职")
@NotNull(message = "是否在岗不可为空") @NotNull(message = "是否在岗不可为空")
@ExcelProperty(value ="在职状态") @ExcelProperty(value ="在职状态")
private String workingStatus; private String workingStatus;
......
...@@ -19,7 +19,6 @@ package com.yifu.cloud.plus.v1.yifu.archives.vo; ...@@ -19,7 +19,6 @@ package com.yifu.cloud.plus.v1.yifu.archives.vo;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth; import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity; import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import java.time.LocalDateTime; import java.time.LocalDateTime;
......
...@@ -18,6 +18,7 @@ package com.yifu.cloud.plus.v1.yifu.archives.vo; ...@@ -18,6 +18,7 @@ package com.yifu.cloud.plus.v1.yifu.archives.vo;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth; import com.alibaba.excel.annotation.write.style.ColumnWidth;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.Past; import javax.validation.constraints.Past;
...@@ -309,10 +310,22 @@ public class EmployeeProjectExportVO{ ...@@ -309,10 +310,22 @@ public class EmployeeProjectExportVO{
private Integer contractStatus; private Integer contractStatus;
/** /**
* 业务类型 * 业务类型一级分类
*/ */
@ExcelProperty(value ="业务类型") @ExcelProperty(value ="业务类型一级分类")
private String businessType; private String businessPrimaryType;
/**
* 业务类型二级分类
*/
@ExcelProperty(value ="业务类型二级分类")
private String businessSecondType;
/**
* 业务类型三级分类
*/
@ExcelProperty(value ="业务类型三级分类")
private String businessThirdType;
/** /**
* 商险状态(字典) * 商险状态(字典)
......
...@@ -24,6 +24,7 @@ import javax.validation.constraints.NotNull; ...@@ -24,6 +24,7 @@ import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.Date;
/** /**
* 项目档案表excel对应的实体 * 项目档案表excel对应的实体
...@@ -189,13 +190,13 @@ public class EmployeeVO implements Serializable { ...@@ -189,13 +190,13 @@ public class EmployeeVO implements Serializable {
* 入学时间 * 入学时间
*/ */
@ExcelProperty(value = "入学时间") @ExcelProperty(value = "入学时间")
private LocalDate admissionDate; private Date admissionDate;
/** /**
* 毕业时间 * 毕业时间
*/ */
@ExcelProperty(value = "毕业时间") @ExcelProperty(value = "毕业时间")
private LocalDate gradutionDate; private Date gradutionDate;
/** /**
* 备注 * 备注
......
package com.yifu.cloud.plus.v1.yifu.archives.vo; package com.yifu.cloud.plus.v1.yifu.archives.vo;
import cn.hutool.core.date.DateTime;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpFamily; import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpFamily;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
......
package com.yifu.cloud.plus.v1.yifu.archives.vo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @Author fxj
* @Date 2022/6/27
* @Description
* @Version 1.0
*/
@Data
public class TCertRecordVo implements Serializable {
/**
* 员工ID
*/
@ExcelAttribute(name = "员工ID" )
@Schema(description ="员工ID")
private String empId;
/**
* 员工姓名
*/
@ExcelAttribute(name = "员工姓名" )
@Schema(description ="员工姓名")
private String empName;
/**
* 员工身份证
*/
@ExcelAttribute(name = "员工身份证" )
@Schema(description ="员工身份证")
private String empIdcard;
/**
* 项目名称
*/
@ExcelAttribute(name = "项目名称" )
@Schema(description ="项目名称")
private String projectName;
/**
* 项目编码
*/
@ExcelAttribute(name = "项目编码" )
@Schema(description ="项目编码")
private String projectCode;
/**
* 岗位
*/
@ExcelAttribute(name = "岗位" )
@Schema(description ="岗位")
private String post;
/**
* 合同开始时间
*/
@ExcelAttribute(name = "合同开始时间" )
@Schema(description ="合同开始时间")
private LocalDateTime contractStart;
/**
* 合同截止时间
*/
@ExcelAttribute(name = "合同截止时间" )
@Schema(description ="合同截止时间")
private LocalDateTime contractEnd;
/**
* 开具当天时间
*/
@ExcelAttribute(name = "开具当天时间" )
@Schema(description ="开具当天时间")
private LocalDateTime openCurTime;
/**
* 印章名称
*/
@ExcelAttribute(name = "印章名称" )
@Schema(description ="印章名称")
private String seal;
/**
* 创建者
*/
@ExcelAttribute(name = "创建者" )
@Schema(description ="创建者")
private String createBy;
/**
* 更新人
*/
@ExcelAttribute(name = "更新人" )
@Schema(description ="更新人")
private String updateBy;
/**
* 创建人姓名
*/
@ExcelAttribute(name = "创建人姓名" )
@Schema(description ="创建人姓名")
private String createName;
/**
* 创建时间
*/
@ExcelAttribute(name = "创建时间" )
@Schema(description ="创建时间")
private LocalDateTime createTime;
/**
* 更新时间
*/
@ExcelAttribute(name = "更新时间" )
@Schema(description ="更新时间")
private LocalDateTime updateTime;
/**
* 证明类型:0 在职 1 离职2劳动合同解除 3调档函4.代缴证明
*/
@ExcelAttribute(name = "证明类型:0 在职 1 离职2劳动合同解除 3调档函4.代缴证明" )
@Schema(description ="证明类型:0 在职 1 离职2劳动合同解除 3调档函4.代缴证明")
private String type;
/**
* 离职时间
*/
@ExcelAttribute(name = "离职时间" )
@Schema(description ="离职时间")
private LocalDateTime leaveTime;
/**
* 派减原因
*/
@ExcelAttribute(name = "派减原因" )
@Schema(description ="派减原因")
private String leaveReason;
/**
* 性别:0男 1女
*/
@ExcelAttribute(name = "性别:0男 1女" )
@Schema(description ="性别:0男 1女")
private String sex;
/**
* 入职时间(来我单位时间)
*/
@ExcelAttribute(name = "入职时间(来我单位时间)" )
@Schema(description ="入职时间(来我单位时间)")
private LocalDateTime entryTime;
/**
* 签订合同时间-第一次
*/
@ExcelAttribute(name = "签订合同时间-第一次" )
@Schema(description ="签订合同时间-第一次")
private LocalDateTime firstContractTime;
/**
* 开具人
*/
@ExcelAttribute(name = "开具人" )
@Schema(description ="开具人")
private String opener;
/**
* 开具时间
*/
@ExcelAttribute(name = "开具时间" )
@Schema(description ="开具时间")
private LocalDateTime openTime;
/**
* 介绍单位
*/
@ExcelAttribute(name = "介绍单位" )
@Schema(description ="介绍单位")
private String introductionUnit;
/**
* 参保时间
*/
@ExcelAttribute(name = "参保时间" )
@Schema(description ="参保时间")
private LocalDateTime socialTime;
}
package com.yifu.cloud.plus.v1.yifu.archives.vo; package com.yifu.cloud.plus.v1.yifu.archives.vo;
import cn.hutool.core.date.DateTime;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpWorkRecording; import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpWorkRecording;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
......
...@@ -2,6 +2,7 @@ package com.yifu.cloud.plus.v1.yifu.archives.controller; ...@@ -2,6 +2,7 @@ package com.yifu.cloud.plus.v1.yifu.archives.controller;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TAttaInfo; import com.yifu.cloud.plus.v1.yifu.archives.entity.TAttaInfo;
import com.yifu.cloud.plus.v1.yifu.archives.service.FileUploadService;
import com.yifu.cloud.plus.v1.yifu.archives.service.TAttaInfoService; import com.yifu.cloud.plus.v1.yifu.archives.service.TAttaInfoService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common; import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.OSSUtil; import com.yifu.cloud.plus.v1.yifu.common.core.util.OSSUtil;
...@@ -17,7 +18,6 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -17,7 +18,6 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.time.LocalDateTime;
import java.util.List; import java.util.List;
/** /**
...@@ -36,6 +36,9 @@ public class FileUploadController { ...@@ -36,6 +36,9 @@ public class FileUploadController {
@Autowired @Autowired
private TAttaInfoService tAttaInfoService; private TAttaInfoService tAttaInfoService;
@Autowired
private FileUploadService fileUploadService;
/** /**
* @Author fxj * @Author fxj
* @Description * @Description
...@@ -52,60 +55,12 @@ public class FileUploadController { ...@@ -52,60 +55,12 @@ public class FileUploadController {
/*@ApiImplicitParams({ /*@ApiImplicitParams({
@ApiImplicitParam(name = "file", value = "Form文件上传", required = true, dataType = "__file", paramType = "form"), @ApiImplicitParam(name = "file", value = "Form文件上传", required = true, dataType = "__file", paramType = "form"),
@ApiImplicitParam(name = "filePath", value = "文件上传路径", required = false, dataType = "String", paramType = "form"), @ApiImplicitParam(name = "filePath", value = "文件上传路径", required = false, dataType = "String", paramType = "form"),
@ApiImplicitParam(name = "type", value = "关系类型(0客户附件1联系人附件2跟进记录附件3合同附件4合同归档附件5报价单6招标信息7业务评估)", required = true, dataType = "int", paramType = "form"), @ApiImplicitParam(name = "type", value = "关系类型(0客户附件1联系人附件2跟进记录附件3合同附件4合同归档附件5报价单6招标信息7业务评估8电子档案)", required = true, dataType = "int", paramType = "form"),
@ApiImplicitParam(name = "domain", value = "实体id(传入就插入对应关系,用于编辑)", required = false, paramType = "form") @ApiImplicitParam(name = "domain", value = "实体id(传入就插入对应关系,用于编辑)", required = false, paramType = "form")
})*/ })*/
@PostMapping(value = "/ossUploadFile") @PostMapping(value = "/ossUploadFile")
public R<FileVo> uploadImg(@RequestBody MultipartFile file, String filePath, Integer type, String domain) throws IOException { public R<FileVo> uploadImg(@RequestBody MultipartFile file, String filePath, Integer type, String domain) throws IOException {
if (null == file) { return fileUploadService.uploadImg(file,filePath,type,domain);
return R.failed("文件删除异常,请重新上传!");
}
String fileName = file.getOriginalFilename();
if (Common.isEmpty(fileName)) {
return R.failed("文件名不能为空!");
}
if (fileName.length() > 100) {
return R.failed("文件名不能超过100个字符!");
}
//filePath不传默认存储空间的根目录
//jpg,jpeg,png,bmp
String key = "";
if (Common.isNotNull(filePath)) {
key = filePath + "/" + System.currentTimeMillis() + fileName;
} else {
key = System.currentTimeMillis() + fileName;
}
if (!Common.checkFile(key)) {
return R.failed("非法上传类型!");
}
boolean flag = ossUtil.uploadFileByStream(file.getInputStream(), key, null);
FileVo fileVo;
TAttaInfo attaInfo;
URL url;
if (flag) {
log.info("文件:" + fileName + "上传至存储空间" + ossUtil.getBucketName() + "成功!");
attaInfo = initUnitAttaForInsert(fileName, key, file.getSize());
attaInfo.setRelationType(String.valueOf(type));
try {
attaInfo.setDomainId(domain);
attaInfo = tAttaInfoService.add(attaInfo);
} catch (Exception e) {
log.error("OSS文件上传接口异常:" + e.getMessage());
ossUtil.deleteObject(null, key);
return R.failed("fail:" + e.getMessage());
}
//有实体id则插入关系,用于编辑
if (Common.isNotNull(domain)) {
url = ossUtil.getObjectUrl(null, attaInfo.getAttaSrc());
fileVo = new FileVo(attaInfo.getId(), attaInfo.getAttaName(), url.toString());
return R.ok(fileVo, "success");
}
url = ossUtil.getObjectUrl(null, attaInfo.getAttaSrc());
fileVo = new FileVo(attaInfo.getId(), attaInfo.getAttaName(), url.toString());
return R.ok(fileVo, "success");
} else {
return R.failed("fail:上传失败");
}
} }
...@@ -137,32 +92,6 @@ public class FileUploadController { ...@@ -137,32 +92,6 @@ public class FileUploadController {
return R.ok(null,"删除失败!"); return R.ok(null,"删除失败!");
} }
/**
* 对象初始化
* @param fileName
* @param key
* @param fileSize
* @return
*/
private TAttaInfo initUnitAttaForInsert(String fileName, String key, long fileSize) {
TAttaInfo unitAtta = new TAttaInfo();
char slash = '/';
char point = '.';
if (fileName.lastIndexOf(slash) >= 0) {
unitAtta.setAttaName(fileName.substring(fileName.lastIndexOf(slash)));
} else {
unitAtta.setAttaName(fileName);
}
unitAtta.setAttaSize(fileSize);
unitAtta.setAttaSrc(key);
if (key.lastIndexOf(point) >= 0) {
unitAtta.setAttaType(key.substring(key.lastIndexOf(point)));
}
unitAtta.setCreateTime(LocalDateTime.now());
return unitAtta;
}
/** /**
* 获取附件下载地址 * 获取附件下载地址
* *
......
...@@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; ...@@ -22,6 +22,7 @@ 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.yifu.cloud.plus.v1.yifu.archives.entity.TCertRecord; import com.yifu.cloud.plus.v1.yifu.archives.entity.TCertRecord;
import com.yifu.cloud.plus.v1.yifu.archives.service.TCertRecordService; import com.yifu.cloud.plus.v1.yifu.archives.service.TCertRecordService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TCertRecordVo;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog; import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
...@@ -86,6 +87,16 @@ public class TCertRecordController { ...@@ -86,6 +87,16 @@ public class TCertRecordController {
return R.ok(tCertRecordService.getById(id)); return R.ok(tCertRecordService.getById(id));
} }
/**
* 通过员工ID查询证明开具记录相关信息
* @param id 项目档案ID
* @return R
*/
@GetMapping("/getCertRecordInfo" )
public R<TCertRecordVo> getCertRecordInfo(@RequestParam(value = "id" ) String id) {
return tCertRecordService.getCertRecordInfo(id);
}
/** /**
* 新增证明开具记录表 * 新增证明开具记录表
* @param tCertRecord 证明开具记录表 * @param tCertRecord 证明开具记录表
......
...@@ -17,13 +17,9 @@ ...@@ -17,13 +17,9 @@
package com.yifu.cloud.plus.v1.yifu.archives.controller; package com.yifu.cloud.plus.v1.yifu.archives.controller;
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.yifu.cloud.plus.v1.yifu.archives.entity.TElecEmployeeInfo; import com.yifu.cloud.plus.v1.yifu.archives.entity.TElecEmployeeInfo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo;
import com.yifu.cloud.plus.v1.yifu.archives.service.TElecEmployeeInfoService; import com.yifu.cloud.plus.v1.yifu.archives.service.TElecEmployeeInfoService;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmployeeInfoService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog; import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
...@@ -50,8 +46,6 @@ public class TElecEmployeeInfoController { ...@@ -50,8 +46,6 @@ public class TElecEmployeeInfoController {
private final TElecEmployeeInfoService tElecEmployeeInfoService; private final TElecEmployeeInfoService tElecEmployeeInfoService;
private final TEmployeeInfoService tEmployeeInfoService;
/** /**
* 分页查询 * 分页查询
* @param page 分页对象 * @param page 分页对象
...@@ -126,12 +120,7 @@ public class TElecEmployeeInfoController { ...@@ -126,12 +120,7 @@ public class TElecEmployeeInfoController {
@SysLog("通过身份证号查询人员档案" ) @SysLog("通过身份证号查询人员档案" )
@PostMapping("/getEmpInfo" ) @PostMapping("/getEmpInfo" )
public R getEmpInfoByCard(@RequestParam String idCard) { public R getEmpInfoByCard(@RequestParam String idCard) {
TEmployeeInfo tEmployeeInfo = tEmployeeInfoService.getOne((Wrappers.<TEmployeeInfo>query().lambda() return R.ok(tElecEmployeeInfoService.getEmpInfoByCard(idCard));
.eq(TEmployeeInfo::getEmpIdcard,idCard)));
if (Common.isNotNull(tEmployeeInfo)) {
return R.ok(tEmployeeInfo);
}
return R.failed("未找到身份证号对应的档案信息");
} }
/** /**
...@@ -142,7 +131,7 @@ public class TElecEmployeeInfoController { ...@@ -142,7 +131,7 @@ public class TElecEmployeeInfoController {
@PostMapping("/importZip") @PostMapping("/importZip")
@Operation(summary = "批量导入电子档案", description = "批量导入电子档案") @Operation(summary = "批量导入电子档案", description = "批量导入电子档案")
@SysLog("批量导入电子档案" ) @SysLog("批量导入电子档案" )
public R<Boolean> importZip(@RequestParam("file") MultipartFile file) { public R<Boolean> importZip(@RequestBody MultipartFile file) {
return this.tElecEmployeeInfoService.importZip(file); return this.tElecEmployeeInfoService.importZip(file);
} }
} }
...@@ -17,32 +17,24 @@ ...@@ -17,32 +17,24 @@
package com.yifu.cloud.plus.v1.yifu.archives.controller; package com.yifu.cloud.plus.v1.yifu.archives.controller;
import com.alibaba.excel.EasyExcel;
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.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpDisabilityInfo; import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpDisabilityInfo;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmpDisabilityInfoService; import com.yifu.cloud.plus.v1.yifu.archives.service.TEmpDisabilityInfoService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.DisabilitySearchVo; import com.yifu.cloud.plus.v1.yifu.archives.vo.DisabilitySearchVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpDisabilityExcelVO;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common; import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage; import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ExcelUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog; import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -120,7 +112,7 @@ public class TEmpDisabilityInfoController { ...@@ -120,7 +112,7 @@ public class TEmpDisabilityInfoController {
@PutMapping @PutMapping
@PreAuthorize("@pms.hasPermission('archives_tempdisabilityinfo_edit')" ) @PreAuthorize("@pms.hasPermission('archives_tempdisabilityinfo_edit')" )
public R<Boolean> updateById(@RequestBody TEmpDisabilityInfo tEmpDisabilityInfo) { public R<Boolean> updateById(@RequestBody TEmpDisabilityInfo tEmpDisabilityInfo) {
return R.ok(tEmpDisabilityInfoService.updateById(tEmpDisabilityInfo)); return tEmpDisabilityInfoService.updateByIdDiy(tEmpDisabilityInfo);
} }
/** /**
...@@ -158,66 +150,13 @@ public class TEmpDisabilityInfoController { ...@@ -158,66 +150,13 @@ public class TEmpDisabilityInfoController {
* @Author fxj * @Author fxj
* @Date 2019-08-16 * @Date 2019-08-16
**/ **/
@SneakyThrows
@Operation(description = "批量新增员工伤残信息 hasPermission('archives_tempdisabilityinfo_importListAdd')") @Operation(description = "批量新增员工伤残信息 hasPermission('archives_tempdisabilityinfo_importListAdd')")
@SysLog("批量新增员工伤残信息") @SysLog("批量新增员工伤残信息")
@PostMapping("/importListAdd") @PostMapping("/importListAdd")
@PreAuthorize("@pms.hasPermission('archives_tempdisabilityinfo_importListAdd')") @PreAuthorize("@pms.hasPermission('archives_tempdisabilityinfo_importListAdd')")
public R<List<ErrorMessage>> importListAdd(@RequestBody MultipartFile file){ public R<List<ErrorMessage>> importListAdd(@RequestBody MultipartFile file){
List<ErrorMessage> errorMessageList = new ArrayList<>(); return tEmpDisabilityInfoService.importTmpDisabilityDiy(file.getInputStream());
ExcelUtil<EmpDisabilityExcelVO> util1 = new ExcelUtil<>(EmpDisabilityExcelVO.class);;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try {
EasyExcel.read(file.getInputStream(), EmpDisabilityExcelVO.class, new ReadListener<EmpDisabilityExcelVO>() {
/**
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
/**
*临时存储
*/
private List<EmpDisabilityExcelVO> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@Override
public void invoke(EmpDisabilityExcelVO data, AnalysisContext context) {
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex+1);
ErrorMessage errorMessage = util1.checkEntity(data, data.getRowIndex());
if (Common.isNotNull(errorMessage)){
errorMessageList.add(errorMessage);
}else {
cachedDataList.add(data);
}
if (cachedDataList.size() >= BATCH_COUNT) {
saveData();
// 存储完成清理 list
cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
saveData();
}
/**
* 加上存储数据库
*/
private void saveData() {
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
tEmpDisabilityInfoService.importTmpDisability(cachedDataList,errorMessageList);
log.info("存储数据库成功!");
}
}).sheet().doRead();
}catch (Exception e){
log.error(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR,e);
return R.failed(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR);
}
return R.ok(errorMessageList);
} }
} }
...@@ -17,32 +17,25 @@ ...@@ -17,32 +17,25 @@
package com.yifu.cloud.plus.v1.yifu.archives.controller; package com.yifu.cloud.plus.v1.yifu.archives.controller;
import com.alibaba.excel.EasyExcel;
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.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpEducation; import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpEducation;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmpEducationService; import com.yifu.cloud.plus.v1.yifu.archives.service.TEmpEducationService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EducationSearchVo; import com.yifu.cloud.plus.v1.yifu.archives.vo.EducationSearchVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationUpdateExcelVo;
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.util.Common; import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage; import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ExcelUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog; import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -159,66 +152,13 @@ public class TEmpEducationController { ...@@ -159,66 +152,13 @@ public class TEmpEducationController {
* @Author fxj * @Author fxj
* @Date 2019-08-16 * @Date 2019-08-16
**/ **/
@SneakyThrows
@Operation(description = "批量新增员工学历信息 hasPermission('archives_education_importListAdd')") @Operation(description = "批量新增员工学历信息 hasPermission('archives_education_importListAdd')")
@SysLog("批量新增员工学历信息") @SysLog("批量新增员工学历信息")
@PostMapping("/importListAdd") @PostMapping("/importListAdd")
@PreAuthorize("@pms.hasPermission('archives_education_importListAdd')") @PreAuthorize("@pms.hasPermission('archives_education_importListAdd')")
public R<List<ErrorMessage>> importListAdd(@RequestBody MultipartFile file) { public R<List<ErrorMessage>> importListAdd(@RequestBody MultipartFile file) {
List<ErrorMessage> errorMessageList = new ArrayList<>(); return tEmpEducationService.importEmpEducationDiy(file.getInputStream());
ExcelUtil<EmpEducationUpdateExcelVo> util1 = new ExcelUtil<>(EmpEducationUpdateExcelVo.class);;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try {
EasyExcel.read(file.getInputStream(), EmpEducationUpdateExcelVo.class, new ReadListener<EmpEducationUpdateExcelVo>() {
/**
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
/**
*临时存储
*/
private List<EmpEducationUpdateExcelVo> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@Override
public void invoke(EmpEducationUpdateExcelVo data, AnalysisContext context) {
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex+1);
ErrorMessage errorMessage = util1.checkEntity(data, data.getRowIndex());
if (Common.isNotNull(errorMessage)){
errorMessageList.add(errorMessage);
}else {
cachedDataList.add(data);
}
if (cachedDataList.size() >= BATCH_COUNT) {
saveData();
// 存储完成清理 list
cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
saveData();
}
/**
* 加上存储数据库
*/
private void saveData() {
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
tEmpEducationService.importEmpEducationUpdate(cachedDataList,errorMessageList);
log.info("存储数据库成功!");
}
}).sheet().doRead();
}catch (Exception e){
log.error(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR,e);
return R.failed(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR);
}
return R.ok(errorMessageList);
} }
/** /**
...@@ -229,64 +169,12 @@ public class TEmpEducationController { ...@@ -229,64 +169,12 @@ public class TEmpEducationController {
* @Author fxj * @Author fxj
* @Date 2019-08-16 * @Date 2019-08-16
**/ **/
@SneakyThrows
@Operation(description = "批量更新员工学历信息 hasPermission('archives_education_importListUpdate')") @Operation(description = "批量更新员工学历信息 hasPermission('archives_education_importListUpdate')")
@SysLog("批量更新员工学历信息") @SysLog("批量更新员工学历信息")
@PostMapping("/importListUpate") @PostMapping("/importListUpate")
@PreAuthorize("@pms.hasPermission('archives_education_importListUpdate')") @PreAuthorize("@pms.hasPermission('archives_education_importListUpdate')")
public R<List<ErrorMessage>> importListUpate(@RequestBody MultipartFile file) { public R<List<ErrorMessage>> importListUpate(@RequestBody MultipartFile file) {
List<ErrorMessage> errorMessageList = new ArrayList<>(); return tEmpEducationService.importEmpEducationUpdateDiy(file.getInputStream());
ExcelUtil<EmpEducationUpdateExcelVo> util1 = new ExcelUtil<>(EmpEducationUpdateExcelVo.class);;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try {
EasyExcel.read(file.getInputStream(), EmpEducationUpdateExcelVo.class, new ReadListener<EmpEducationUpdateExcelVo>() {
/**
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
/**
*临时存储
*/
private List<EmpEducationUpdateExcelVo> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@Override
public void invoke(EmpEducationUpdateExcelVo data, AnalysisContext context) {
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex+1);
ErrorMessage errorMessage = util1.checkEntity(data, data.getRowIndex());
if (Common.isNotNull(errorMessage)){
errorMessageList.add(errorMessage);
}else {
cachedDataList.add(data);
}
if (cachedDataList.size() >= BATCH_COUNT) {
saveData();
// 存储完成清理 list
cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
saveData();
}
/**
* 加上存储数据库
*/
private void saveData() {
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
tEmpEducationService.importEmpEducationUpdate(cachedDataList,errorMessageList);
log.info("存储数据库成功!");
}
}).sheet().doRead();
}catch (Exception e){
log.error(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR,e);
return R.failed(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR);
}
return R.ok(errorMessageList);
} }
} }
...@@ -17,32 +17,25 @@ ...@@ -17,32 +17,25 @@
package com.yifu.cloud.plus.v1.yifu.archives.controller; package com.yifu.cloud.plus.v1.yifu.archives.controller;
import com.alibaba.excel.EasyExcel;
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.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpFamily; import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpFamily;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmpFamilyService; import com.yifu.cloud.plus.v1.yifu.archives.service.TEmpFamilyService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpFamilyExcelVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.FamilySearchVO; import com.yifu.cloud.plus.v1.yifu.archives.vo.FamilySearchVO;
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.util.Common; import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage; import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ExcelUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog; import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -183,63 +176,12 @@ public class TEmpFamilyController { ...@@ -183,63 +176,12 @@ public class TEmpFamilyController {
* @Author fxj * @Author fxj
* @Date 2019-08-16 * @Date 2019-08-16
**/ **/
@SneakyThrows
@Operation(description = "批量新增员工家庭信息 hasPermission('archives-family-batch-import')") @Operation(description = "批量新增员工家庭信息 hasPermission('archives-family-batch-import')")
@SysLog("批量新增员工家庭信息") @SysLog("批量新增员工家庭信息")
@PostMapping("/importListAdd") @PostMapping("/importListAdd")
@PreAuthorize("@pms.hasPermission('archives-family-batch-import')") @PreAuthorize("@pms.hasPermission('archives-family-batch-import')")
public R<List<ErrorMessage>> importListAdd(@RequestBody MultipartFile file){ public R<List<ErrorMessage>> importListAdd(@RequestBody MultipartFile file){
List<ErrorMessage> errorMessageList = new ArrayList<>(); return tEmpFamilyService.importEmpFamilyDiy(file.getInputStream());
ExcelUtil<EmpFamilyExcelVO> util1 = new ExcelUtil<>(EmpFamilyExcelVO.class);;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try {
EasyExcel.read(file.getInputStream(), EmpFamilyExcelVO.class, new ReadListener<EmpFamilyExcelVO>() {
/**
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
/**
*临时存储
*/
private List<EmpFamilyExcelVO> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@Override
public void invoke(EmpFamilyExcelVO data, AnalysisContext context) {
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex+1);
ErrorMessage errorMessage = util1.checkEntity(data, data.getRowIndex());
if (Common.isNotNull(errorMessage)){
errorMessageList.add(errorMessage);
}else {
cachedDataList.add(data);
}
if (cachedDataList.size() >= BATCH_COUNT) {
saveData();
// 存储完成清理 list
cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
saveData();
}
/**
* 加上存储数据库
*/
private void saveData() {
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
tEmpFamilyService.importEmpFamily(cachedDataList,errorMessageList);
log.info("存储数据库成功!");
}
}).sheet().doRead();
}catch (Exception e){
log.error(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR,e);
return R.failed(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR);
}
return R.ok(errorMessageList);
} }
} }
...@@ -17,32 +17,24 @@ ...@@ -17,32 +17,24 @@
package com.yifu.cloud.plus.v1.yifu.archives.controller; package com.yifu.cloud.plus.v1.yifu.archives.controller;
import com.alibaba.excel.EasyExcel;
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.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpProfessionalQualification; import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpProfessionalQualification;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmpProfessionalQualificationService; import com.yifu.cloud.plus.v1.yifu.archives.service.TEmpProfessionalQualificationService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.CertifySearchVo; import com.yifu.cloud.plus.v1.yifu.archives.vo.CertifySearchVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpCertificateExcelVO;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common; import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage; import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ExcelUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog; import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -155,63 +147,12 @@ public class TEmpProfessionalQualificationController { ...@@ -155,63 +147,12 @@ public class TEmpProfessionalQualificationController {
* @Author fxj * @Author fxj
* @Date 2019-08-16 * @Date 2019-08-16
**/ **/
@SneakyThrows
@Operation(description = "批量新增员工证书信息 hasPermission('archives-professionalqualification-batch-import')") @Operation(description = "批量新增员工证书信息 hasPermission('archives-professionalqualification-batch-import')")
@SysLog("批量新增员工证书信息") @SysLog("批量新增员工证书信息")
@PostMapping("/importListAdd") @PostMapping("/importListAdd")
@PreAuthorize("@pms.hasPermission('archives-professionalqualification-batch-import')") @PreAuthorize("@pms.hasPermission('archives-professionalqualification-batch-import')")
public R<List<ErrorMessage>> importListAdd(@RequestBody MultipartFile file) { public R<List<ErrorMessage>> importListAdd(@RequestBody MultipartFile file) {
List<ErrorMessage> errorMessageList = new ArrayList<>(); return qualificationService.importEmpCertificateDiy(file.getInputStream());
ExcelUtil<EmpCertificateExcelVO> util1 = new ExcelUtil<>(EmpCertificateExcelVO.class);;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try {
EasyExcel.read(file.getInputStream(), EmpCertificateExcelVO.class, new ReadListener<EmpCertificateExcelVO>() {
/**
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
/**
*临时存储
*/
private List<EmpCertificateExcelVO> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@Override
public void invoke(EmpCertificateExcelVO data, AnalysisContext context) {
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex+1);
ErrorMessage errorMessage = util1.checkEntity(data, data.getRowIndex());
if (Common.isNotNull(errorMessage)){
errorMessageList.add(errorMessage);
}else {
cachedDataList.add(data);
}
if (cachedDataList.size() >= BATCH_COUNT) {
saveData();
// 存储完成清理 list
cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
saveData();
}
/**
* 加上存储数据库
*/
private void saveData() {
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
qualificationService.importEmpCertificate(cachedDataList,errorMessageList);
log.info("存储数据库成功!");
}
}).sheet().doRead();
}catch (Exception e){
log.error(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR,e);
return R.failed(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR);
}
return R.ok(errorMessageList);
} }
} }
...@@ -17,32 +17,25 @@ ...@@ -17,32 +17,25 @@
package com.yifu.cloud.plus.v1.yifu.archives.controller; package com.yifu.cloud.plus.v1.yifu.archives.controller;
import com.alibaba.excel.EasyExcel;
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.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpWorkRecording; import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpWorkRecording;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmpWorkRecordingService; import com.yifu.cloud.plus.v1.yifu.archives.service.TEmpWorkRecordingService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpWorkRecordExcelVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.WorkRecordSearchVO; import com.yifu.cloud.plus.v1.yifu.archives.vo.WorkRecordSearchVO;
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.util.Common; import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage; import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ExcelUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog; import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.log4j.Log4j2; import lombok.extern.log4j.Log4j2;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.util.ArrayList;
import java.util.List; import java.util.List;
...@@ -156,65 +149,12 @@ public class TEmpWorkRecordingController { ...@@ -156,65 +149,12 @@ public class TEmpWorkRecordingController {
* @Author fxj * @Author fxj
* @Date 2019-08-16 * @Date 2019-08-16
**/ **/
@SneakyThrows
@Operation(description = "批量新增员工工作信息 hasPermission('archives_tempworkrecording_importListAdd')") @Operation(description = "批量新增员工工作信息 hasPermission('archives_tempworkrecording_importListAdd')")
@SysLog("批量新增员工工作信息") @SysLog("批量新增员工工作信息")
@PostMapping("/importListAdd") @PostMapping("/importListAdd")
@PreAuthorize("@pms.hasPermission('archives_tempworkrecording_importListAdd')") @PreAuthorize("@pms.hasPermission('archives_tempworkrecording_importListAdd')")
public R<List<ErrorMessage>> importListAdd(@RequestBody MultipartFile file) { public R<List<ErrorMessage>> importListAdd(@RequestBody MultipartFile file) {
return tEmpWorkRecordingService.importEmpWorkRecordDiy(file.getInputStream());
List<com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage> errorMessageList = new ArrayList<>();
ExcelUtil<EmpWorkRecordExcelVO> util1 = new ExcelUtil<>(EmpWorkRecordExcelVO.class);;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try {
EasyExcel.read(file.getInputStream(), EmpWorkRecordExcelVO.class, new ReadListener<EmpWorkRecordExcelVO>() {
/**
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
/**
*临时存储
*/
private List<EmpWorkRecordExcelVO> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@Override
public void invoke(EmpWorkRecordExcelVO data, AnalysisContext context) {
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex+1);
com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage errorMessage = util1.checkEntity(data, data.getRowIndex());
if (Common.isNotNull(errorMessage)){
errorMessageList.add(errorMessage);
}else {
cachedDataList.add(data);
}
if (cachedDataList.size() >= BATCH_COUNT) {
saveData();
// 存储完成清理 list
cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
saveData();
}
/**
* 加上存储数据库
*/
private void saveData() {
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
tEmpWorkRecordingService.importEmpWorkRecord(cachedDataList,errorMessageList);
log.info("存储数据库成功!");
}
}).sheet().doRead();
}catch (Exception e){
log.error(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR,e);
return R.failed(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR);
}
return R.ok(errorMessageList);
} }
} }
...@@ -230,8 +230,8 @@ public class TEmployeeProjectController { ...@@ -230,8 +230,8 @@ public class TEmployeeProjectController {
* @Date 2022-06-21 * @Date 2022-06-21
**/ **/
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, EmployeeProjectExportVO projectDTO, @RequestParam(name = "idstr", required = false)String idstr, public void export(HttpServletResponse response, @RequestParam(name = "idstr", required = false)String idstr,
@RequestBody List<String> exportFields) { @RequestBody List<String> exportFields, EmployeeProjectExportVO projectDTO) {
tEmployeeProjectService.listExportProject(response,projectDTO,idstr,exportFields); tEmployeeProjectService.listExportProject(response,projectDTO,idstr,exportFields);
} }
......
package com.yifu.cloud.plus.v1.yifu.archives.service;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.FileVo;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
/**
* 文件上传
*
* @author pwang
* @date 2022-07-27 16:16:07
*/
public interface FileUploadService {
R<FileVo> uploadImg(MultipartFile file, String filePath, Integer type, String domain) throws IOException;
}
...@@ -19,6 +19,8 @@ package com.yifu.cloud.plus.v1.yifu.archives.service; ...@@ -19,6 +19,8 @@ package com.yifu.cloud.plus.v1.yifu.archives.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TCertRecord; import com.yifu.cloud.plus.v1.yifu.archives.entity.TCertRecord;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TCertRecordVo;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
/** /**
* 证明开具记录表 * 证明开具记录表
...@@ -28,4 +30,5 @@ import com.yifu.cloud.plus.v1.yifu.archives.entity.TCertRecord; ...@@ -28,4 +30,5 @@ import com.yifu.cloud.plus.v1.yifu.archives.entity.TCertRecord;
*/ */
public interface TCertRecordService extends IService<TCertRecord> { public interface TCertRecordService extends IService<TCertRecord> {
R<TCertRecordVo> getCertRecordInfo(String id);
} }
...@@ -42,4 +42,14 @@ public interface TElecEmployeeInfoService extends IService<TElecEmployeeInfo> { ...@@ -42,4 +42,14 @@ public interface TElecEmployeeInfoService extends IService<TElecEmployeeInfo> {
* @date: 2022/6/24 * @date: 2022/6/24
*/ */
R<Boolean> importZip(MultipartFile file); R<Boolean> importZip(MultipartFile file);
/**
* @description: 通过身份证号查询人员档案
* @param idCard 身份证号
* @return: R
* @author: huyc
* @date: 2022/6/27
*/
R getEmpInfoByCard(String idCard);
} }
...@@ -26,6 +26,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpDisabilityExcelVO; ...@@ -26,6 +26,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpDisabilityExcelVO;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage; import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import java.io.InputStream;
import java.util.List; import java.util.List;
/** /**
...@@ -43,4 +44,8 @@ public interface TEmpDisabilityInfoService extends IService<TEmpDisabilityInfo> ...@@ -43,4 +44,8 @@ public interface TEmpDisabilityInfoService extends IService<TEmpDisabilityInfo>
IPage<TEmpDisabilityInfo> pageDiy(Page page, DisabilitySearchVo searchVo); IPage<TEmpDisabilityInfo> pageDiy(Page page, DisabilitySearchVo searchVo);
List<TEmpDisabilityInfo> getTEmpDisabilityInfoNoPage(DisabilitySearchVo searchVo); List<TEmpDisabilityInfo> getTEmpDisabilityInfoNoPage(DisabilitySearchVo searchVo);
R<Boolean> updateByIdDiy(TEmpDisabilityInfo tEmpDisabilityInfo);
R<List<ErrorMessage>> importTmpDisabilityDiy(InputStream inputStream);
} }
...@@ -27,6 +27,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationUpdateExcelVo; ...@@ -27,6 +27,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationUpdateExcelVo;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage; import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import java.io.InputStream;
import java.util.List; import java.util.List;
/** /**
...@@ -50,4 +51,9 @@ public interface TEmpEducationService extends IService<TEmpEducation> { ...@@ -50,4 +51,9 @@ public interface TEmpEducationService extends IService<TEmpEducation> {
IPage<TEmpEducation> pageDiy(Page page, EducationSearchVo tEmpEducation); IPage<TEmpEducation> pageDiy(Page page, EducationSearchVo tEmpEducation);
List<TEmpEducation> getTEmpEducationNoPage(EducationSearchVo searchVo); List<TEmpEducation> getTEmpEducationNoPage(EducationSearchVo searchVo);
R<List<ErrorMessage>> importEmpEducationDiy(InputStream inputStream);
R<List<ErrorMessage>> importEmpEducationUpdateDiy(InputStream inputStream);
} }
...@@ -26,6 +26,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.FamilySearchVO; ...@@ -26,6 +26,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.FamilySearchVO;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage; import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import java.io.InputStream;
import java.util.List; import java.util.List;
/** /**
...@@ -45,4 +46,6 @@ public interface TEmpFamilyService extends IService<TEmpFamily> { ...@@ -45,4 +46,6 @@ public interface TEmpFamilyService extends IService<TEmpFamily> {
IPage<TEmpFamily> pageDiy(Page page, FamilySearchVO tEmpFamily); IPage<TEmpFamily> pageDiy(Page page, FamilySearchVO tEmpFamily);
List<TEmpFamily> getTEmpFamilyNoPage(FamilySearchVO family); List<TEmpFamily> getTEmpFamilyNoPage(FamilySearchVO family);
R<List<ErrorMessage>> importEmpFamilyDiy(InputStream fileInputStream);
} }
...@@ -26,6 +26,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpCertificateExcelVO; ...@@ -26,6 +26,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpCertificateExcelVO;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage; import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import java.io.InputStream;
import java.util.List; import java.util.List;
/** /**
...@@ -43,4 +44,6 @@ public interface TEmpProfessionalQualificationService extends IService<TEmpProfe ...@@ -43,4 +44,6 @@ public interface TEmpProfessionalQualificationService extends IService<TEmpProfe
List<TEmpProfessionalQualification> getDataNoPage(CertifySearchVo searchVo); List<TEmpProfessionalQualification> getDataNoPage(CertifySearchVo searchVo);
IPage<TEmpProfessionalQualification> pageDiy(Page page, CertifySearchVo searchVo); IPage<TEmpProfessionalQualification> pageDiy(Page page, CertifySearchVo searchVo);
R<List<ErrorMessage>> importEmpCertificateDiy(InputStream inputStream);
} }
...@@ -26,6 +26,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.WorkRecordSearchVO; ...@@ -26,6 +26,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.WorkRecordSearchVO;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage; import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import java.io.InputStream;
import java.util.List; import java.util.List;
/** /**
...@@ -45,4 +46,6 @@ public interface TEmpWorkRecordingService extends IService<TEmpWorkRecording> { ...@@ -45,4 +46,6 @@ public interface TEmpWorkRecordingService extends IService<TEmpWorkRecording> {
IPage<TEmpWorkRecording> pageDiy(Page page, WorkRecordSearchVO tEmpWorkRecording); IPage<TEmpWorkRecording> pageDiy(Page page, WorkRecordSearchVO tEmpWorkRecording);
List<TEmpWorkRecording> getTEmpWorkRecordingNoPage(WorkRecordSearchVO searchVo); List<TEmpWorkRecording> getTEmpWorkRecordingNoPage(WorkRecordSearchVO searchVo);
R<List<ErrorMessage>> importEmpWorkRecordDiy(InputStream inputStream);
} }
package com.yifu.cloud.plus.v1.yifu.archives.service.impl;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TAttaInfo;
import com.yifu.cloud.plus.v1.yifu.archives.service.FileUploadService;
import com.yifu.cloud.plus.v1.yifu.archives.service.TAttaInfoService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.OSSUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.vo.FileVo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.net.URL;
import java.time.LocalDateTime;
@Service
@RequiredArgsConstructor
@Slf4j
public class FileUploadServiceImpl implements FileUploadService {
private final OSSUtil ossUtil;
private final TAttaInfoService tAttaInfoService;
@Override
public R<FileVo> uploadImg(MultipartFile file, String filePath, Integer type, String domain) throws IOException {
if (null == file) {
return R.failed("文件删除异常,请重新上传!");
}
String fileName = file.getOriginalFilename();
if (Common.isEmpty(fileName)) {
return R.failed("文件名不能为空!");
}
if (fileName.length() > 100) {
return R.failed("文件名不能超过100个字符!");
}
//filePath不传默认存储空间的根目录
//jpg,jpeg,png,bmp
String key = "";
if (Common.isNotNull(filePath)) {
key = filePath + "/" + System.currentTimeMillis() + fileName;
} else {
key = System.currentTimeMillis() + fileName;
}
if (!Common.checkFile(key)) {
return R.failed("非法上传类型!");
}
boolean flag = ossUtil.uploadFileByStream(file.getInputStream(), key, null);
FileVo fileVo;
TAttaInfo attaInfo;
URL url;
if (flag) {
log.info("文件:" + fileName + "上传至存储空间" + ossUtil.getBucketName() + "成功!");
attaInfo = initUnitAttaForInsert(fileName, key, file.getSize());
attaInfo.setRelationType(String.valueOf(type));
try {
attaInfo.setDomainId(domain);
attaInfo = tAttaInfoService.add(attaInfo);
} catch (Exception e) {
log.error("OSS文件上传接口异常:" + e.getMessage());
ossUtil.deleteObject(null, key);
return R.failed("fail:" + e.getMessage());
}
//有实体id则插入关系,用于编辑
if (Common.isNotNull(domain)) {
url = ossUtil.getObjectUrl(null, attaInfo.getAttaSrc());
fileVo = new FileVo(attaInfo.getId(), attaInfo.getAttaName(), url.toString());
return R.ok(fileVo, "success");
}
url = ossUtil.getObjectUrl(null, attaInfo.getAttaSrc());
fileVo = new FileVo(attaInfo.getId(), attaInfo.getAttaName(), url.toString());
return R.ok(fileVo, "success");
} else {
return R.failed("fail:上传失败");
}
}
/**
* 对象初始化
* @param fileName
* @param key
* @param fileSize
* @return
*/
private TAttaInfo initUnitAttaForInsert(String fileName, String key, long fileSize) {
TAttaInfo unitAtta = new TAttaInfo();
char slash = '/';
char point = '.';
if (fileName.lastIndexOf(slash) >= 0) {
unitAtta.setAttaName(fileName.substring(fileName.lastIndexOf(slash)));
} else {
unitAtta.setAttaName(fileName);
}
unitAtta.setAttaSize(fileSize);
unitAtta.setAttaSrc(key);
if (key.lastIndexOf(point) >= 0) {
unitAtta.setAttaType(key.substring(key.lastIndexOf(point)));
}
unitAtta.setCreateTime(LocalDateTime.now());
return unitAtta;
}
}
...@@ -18,8 +18,17 @@ package com.yifu.cloud.plus.v1.yifu.archives.service.impl; ...@@ -18,8 +18,17 @@ package com.yifu.cloud.plus.v1.yifu.archives.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TCertRecord; import com.yifu.cloud.plus.v1.yifu.archives.entity.TCertRecord;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeProject;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TCertRecordMapper; import com.yifu.cloud.plus.v1.yifu.archives.mapper.TCertRecordMapper;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmployeeInfoMapper;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmployeeProjectMapper;
import com.yifu.cloud.plus.v1.yifu.archives.service.TCertRecordService; import com.yifu.cloud.plus.v1.yifu.archives.service.TCertRecordService;
import com.yifu.cloud.plus.v1.yifu.archives.vo.TCertRecordVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
/** /**
...@@ -28,7 +37,46 @@ import org.springframework.stereotype.Service; ...@@ -28,7 +37,46 @@ import org.springframework.stereotype.Service;
* @author fxj * @author fxj
* @date 2022-06-25 11:05:11 * @date 2022-06-25 11:05:11
*/ */
@RequiredArgsConstructor
@Service @Service
public class TCertRecordServiceImpl extends ServiceImpl<TCertRecordMapper, TCertRecord> implements TCertRecordService { public class TCertRecordServiceImpl extends ServiceImpl<TCertRecordMapper, TCertRecord> implements TCertRecordService {
private final TEmployeeProjectMapper projectMapper;
private final TEmployeeInfoMapper employeeInfoMapper;
@Override
public R<TCertRecordVo> getCertRecordInfo(String id) {
TEmployeeProject project = projectMapper.selectById(id);
if (!Common.isNotNull(project)){
return R.failed(CommonConstants.PARAM_IS_NOT_ERROR);
}
TEmployeeInfo employeeInfo = employeeInfoMapper.selectById(project.getEmpId());
if (!Common.isNotNull(employeeInfo)){
return R.failed(CommonConstants.PARAM_IS_NOT_ERROR);
}
TCertRecordVo vo = new TCertRecordVo();
vo.setEmpIdcard(project.getEmpIdcard());
vo.setEmpId(project.getEmpId());
vo.setEmpName(project.getEmpName());
vo.setPost(project.getPost());
vo.setProjectName(project.getDeptName());
vo.setProjectCode(project.getDeptNo());
// TODO 最新合同时间
vo.setContractStart(null);
vo.setContractEnd(null);
// TODO 派减离职时间和原因
vo.setLeaveTime(employeeInfo.getLeaveTime());
vo.setLeaveReason(employeeInfo.getLeaveReason());
// TODO 第一次合同开始截止时间
vo.setEntryTime(employeeInfo.getCreateTime());
vo.setFirstContractTime(null);
vo.setSex(employeeInfo.getEmpSex());
vo.setIntroductionUnit(CommonConstants.EMPTY_STRING);
vo.setSeal("安徽皖信人力资源管理有限公司");
// TODO 参保时间
vo.setSocialTime(null);
return R.ok(vo);
}
} }
...@@ -16,30 +16,38 @@ ...@@ -16,30 +16,38 @@
*/ */
package com.yifu.cloud.plus.v1.yifu.archives.service.impl; package com.yifu.cloud.plus.v1.yifu.archives.service.impl;
import cn.hutool.core.io.FileTypeUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.CharsetUtil; import cn.hutool.core.util.CharsetUtil;
import cn.hutool.core.util.ZipUtil;
import com.baomidou.mybatisplus.core.metadata.IPage; 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.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TElecEmployeeInfo; import com.yifu.cloud.plus.v1.yifu.archives.entity.TElecEmployeeInfo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TElecEmployeeInfoMapper; import com.yifu.cloud.plus.v1.yifu.archives.mapper.TElecEmployeeInfoMapper;
import com.yifu.cloud.plus.v1.yifu.archives.service.FileUploadService;
import com.yifu.cloud.plus.v1.yifu.archives.service.TElecEmployeeInfoService; import com.yifu.cloud.plus.v1.yifu.archives.service.TElecEmployeeInfoService;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmployeeInfoService;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.SecurityConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; import com.yifu.cloud.plus.v1.yifu.common.core.vo.FileVo;
import org.apache.commons.compress.archivers.zip.ZipFile; import com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprUpmsProperties;
import com.yifu.cloud.plus.v1.yifu.common.dapr.util.HttpDaprUtil;
import lombok.RequiredArgsConstructor;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import java.io.*;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.UUID;
/** /**
* 电子档案信息表 * 电子档案信息表
...@@ -48,8 +56,16 @@ import java.util.UUID; ...@@ -48,8 +56,16 @@ import java.util.UUID;
* @date 2022-06-18 09:39:46 * @date 2022-06-18 09:39:46
*/ */
@Service @Service
@RequiredArgsConstructor
@EnableConfigurationProperties(DaprUpmsProperties.class)
public class TElecEmployeeInfoServiceImpl extends ServiceImpl<TElecEmployeeInfoMapper, TElecEmployeeInfo> implements TElecEmployeeInfoService { public class TElecEmployeeInfoServiceImpl extends ServiceImpl<TElecEmployeeInfoMapper, TElecEmployeeInfo> implements TElecEmployeeInfoService {
private final TEmployeeInfoService tEmployeeInfoService;
private final FileUploadService fileUploadService;
private final DaprUpmsProperties daprUpmsProperties;
@Override @Override
public boolean save(TElecEmployeeInfo entity) { public boolean save(TElecEmployeeInfo entity) {
return super.save(entity); return super.save(entity);
...@@ -62,53 +78,206 @@ public class TElecEmployeeInfoServiceImpl extends ServiceImpl<TElecEmployeeInfoM ...@@ -62,53 +78,206 @@ public class TElecEmployeeInfoServiceImpl extends ServiceImpl<TElecEmployeeInfoM
/** /**
* @description: 解析zip文件包中的多个附件,并生成结算记录 * @description: 解析zip文件包中的多个附件,并生成结算记录
* @param file zip文件包 * @param zipFile zip文件包
* @return: com.yifu.cloud.v1.common.core.util.R<java.lang.Boolean> * @return: com.yifu.cloud.v1.common.core.util.R<java.lang.Boolean>
* @author: wangweiguo * @author: huyc
* @date: 2021/8/19 * @date: 2022/6/27
*/ */
@Override @Override
public R<Boolean> importZip(MultipartFile file) { public R<Boolean> importZip(MultipartFile zipFile) {
//C:\Users\登录用户~1\AppData\Local\Temp\
String pathName = System.getProperty("java.io.tmpdir") + "shpFileCache/";
String dec = System.getProperty("java.io.tmpdir") + "shpFileCache/";
File unzip = null; //获取文件名(包括后缀)
File etractFile = null; String pname = zipFile.getOriginalFilename();
pathName = pathName + pname;
try { try {
String fileType = FileTypeUtil.getType(file.getInputStream()); File file = new File(pathName);
// if (!StringUtils.equalsIgnoreCase(fileType, CommonConstants.ZIP_TYPE)) { zipFile.transferTo(file);
// return R.failed(ErrorCodes.IMPORT_FILE_TYPE_ERROR); // 获取解压出来的文件名 不带后缀
// } unZip(file, dec);
//解析完成删除本次解析中生成的文件 删除此目录下的所有文件
List list = new ArrayList(); deleteFile(dec);
} catch (Exception e) {
e.printStackTrace();
}
return R.ok();
}
etractFile = new File(UUID.randomUUID().toString()); @Override
unzip = ZipUtil.unzip(file.getInputStream(), etractFile, CharsetUtil.CHARSET_GBK); public R getEmpInfoByCard(String idCard) {
TEmployeeInfo tEmployeeInfo = tEmployeeInfoService.getOne((Wrappers.<TEmployeeInfo>query().lambda()
.eq(TEmployeeInfo::getEmpIdcard,idCard)));
if (Common.isNotNull(tEmployeeInfo)) {
return R.ok(tEmployeeInfo);
}
return R.failed("未找到身份证号对应的档案信息");
}
ZipFile zipFile=new ZipFile(unzip); /**
* zip解压
* @param srcFile zip源文件
* @throws RuntimeException 解压失败会抛出运行时异常
*/
private R unZip(File srcFile, String destDirPath) throws RuntimeException {
for (Enumeration<? extends ZipArchiveEntry> e = zipFile.getEntries(); e.hasMoreElements();) { // 调用字典服务,渲染字典值
ZipArchiveEntry entry=e.nextElement(); 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>>> dictMap;
// 电子档案类型
Map<String, Map<String, String>> elecTypeMapData;
Map<String, String> elecTypeMap;
if (dictR == null) {
return R.failed("获取字典失败!");
}else {
dictMap = dictR.getData();
elecTypeMapData = dictMap.get("data");
elecTypeMap = elecTypeMapData.get("elec_archives_type");
}
//记录解压出来的所有文件名
List<String> filesName = new ArrayList<>();
// 判断源文件是否存在
if (!srcFile.exists()) {
throw new RuntimeException(srcFile.getPath() + "所指文件不存在");
}
// 开始解压
ZipFile zipFile = null;
try {
zipFile = new ZipFile(srcFile, CharsetUtil.CHARSET_GBK);
Enumeration<?> entries = zipFile.entries();
if(!entry.isDirectory()){ while (entries.hasMoreElements()) {
BufferedReader br=new BufferedReader(new InputStreamReader(zipFile.getInputStream(entry))); ZipEntry entry = (ZipEntry) entries.nextElement();
//添加进filesName
String empInfo = entry.getName();
// 如果是文件夹,就创建个文件夹
if (entry.isDirectory()) {
String dirPath = destDirPath + "/" + entry.getName();
File dir = new File(dirPath);
dir.mkdirs();
} else {
// 如果是文件,就先创建一个文件,然后用io流把内容copy过去
File targetFile = new File(destDirPath + "/" + entry.getName());
String line = ""; // 保证这个文件的父文件夹必须要存在
if (!targetFile.getParentFile().exists()) {
targetFile.getParentFile().mkdirs();
}
targetFile.createNewFile();
// 将压缩文件内容写入到这个文件中
InputStream is = zipFile.getInputStream(entry);
FileOutputStream fos = new FileOutputStream(targetFile);
int len;
byte[] buf = new byte[1024];
while ((len = is.read(buf)) != -1) {
fos.write(buf, 0, len);
}
while((line = br.readLine()) != null){ R<FileVo> fileVo =fileUploadService.uploadImg(fileCovertMultipartFile(targetFile),"", CommonConstants.EIGHT_INT,"");
if(line.length() > 0){
list.add(line);
if (empInfo.length() > empInfo.lastIndexOf("/") + 1) {
String idCard = empInfo.substring(0,empInfo.indexOf("/"));
String dataType = empInfo.substring(empInfo.indexOf("/") +1,empInfo.lastIndexOf("/"));
String empName = "";
TEmployeeInfo tEmployeeInfo = tEmployeeInfoService.getOne((Wrappers.<TEmployeeInfo>query().lambda()
.eq(TEmployeeInfo::getEmpIdcard,idCard)));
if (Common.isNotNull(tEmployeeInfo)) {
empName = tEmployeeInfo.getEmpName();
}
String attachInfo = empInfo.substring(empInfo.lastIndexOf("/")+1,empInfo.length());
TElecEmployeeInfo tElecEmployeeInfo = new TElecEmployeeInfo();
tElecEmployeeInfo.setEmpIdcard(idCard);
tElecEmployeeInfo.setEmpName(empName);
tElecEmployeeInfo.setAttaInfo(attachInfo);
if (Common.isNotNull(elecTypeMap)) {
tElecEmployeeInfo.setDataType(elecTypeMap.get(dataType));
} }
tElecEmployeeInfo.setFileId(fileVo.getData().getUid());
this.save(tElecEmployeeInfo);
} }
br.close(); // 关流顺序,先打开的后关闭
fos.close();
is.close();
} }
} }
} catch (Exception e) {
throw new RuntimeException("unzip error from ZipUtils", e);
} finally {
if (zipFile != null) {
try {
zipFile.close();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} finally { }
if (etractFile != null) {
FileUtil.del(etractFile);
} }
} }
return R.ok(); return R.ok();
} }
/**
* File转MultipartFile
* @description: File转MultipartFile
* @param file 需要转换的文件
* @return: org.springframework.web.multipart.MultipartFile
* @author: huyc
* @date: 2022/6/27
*/
private MultipartFile fileCovertMultipartFile(File file) {
FileItemFactory factory = new DiskFileItemFactory(16, null);
FileItem item = factory.createItem(file.getName(), "text/plain", true, file.getName());
int bytesRead = 0;
byte[] buffer = new byte[8192];
try {
FileInputStream fis = new FileInputStream(file);
OutputStream os = item.getOutputStream();
while ((bytesRead = fis.read(buffer, 0, 8192)) != -1) {
os.write(buffer, 0, bytesRead);
}
os.close();
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
MultipartFile multipartFile = new CommonsMultipartFile(item);
return multipartFile;
}
/**
* 删除文件
*
* @param filePath
* @return
*/
public static boolean deleteFile(String filePath) {
boolean flag = false;
File file = new File(filePath);
if (!file.exists()) {
return flag;
}
if (!file.isDirectory()) {
return flag;
}
String[] tempList = file.list();
File temp;
for (int i = 0; i < tempList.length; i++) {
if (filePath.endsWith(File.separator)) {
temp = new File(filePath + tempList[i]);
} else {
temp = new File(filePath + File.separator + tempList[i]);
}
if (temp.isFile()) {
temp.delete();
}
if (temp.isDirectory()) {
// 先删除文件夹里面的文件
deleteFile(filePath + "/" + tempList[i]);
// 再删除空文件夹
deleteFile(filePath + "/" + tempList[i]);
flag = true;
}
}
return flag;
}
} }
...@@ -20,7 +20,10 @@ import cn.hutool.core.collection.CollUtil; ...@@ -20,7 +20,10 @@ import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
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.yifu.archives.entity.*; import com.yifu.cloud.plus.v1.yifu.archives.entity.TCustomerInfo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpChangeInfo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeProject;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TSettleDomain;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmpChangeInfoMapper; import com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmpChangeInfoMapper;
import com.yifu.cloud.plus.v1.yifu.archives.service.TCustomerInfoService; import com.yifu.cloud.plus.v1.yifu.archives.service.TCustomerInfoService;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmpChangeInfoService; import com.yifu.cloud.plus.v1.yifu.archives.service.TEmpChangeInfoService;
......
...@@ -18,6 +18,11 @@ package com.yifu.cloud.plus.v1.yifu.archives.service.impl; ...@@ -18,6 +18,11 @@ package com.yifu.cloud.plus.v1.yifu.archives.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ArrayUtil;
import com.alibaba.excel.EasyExcel;
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.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
...@@ -33,14 +38,14 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.DisabilitySearchVo; ...@@ -33,14 +38,14 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.DisabilitySearchVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpDisabilityExcelVO; import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpDisabilityExcelVO;
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.exception.ErrorCodes; import com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common; import com.yifu.cloud.plus.v1.yifu.common.core.util.*;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.MsgUtils;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity; import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
...@@ -49,6 +54,7 @@ import java.util.List; ...@@ -49,6 +54,7 @@ import java.util.List;
* @author fxj * @author fxj
* @date 2022-06-18 09:39:46 * @date 2022-06-18 09:39:46
*/ */
@Log4j2
@RequiredArgsConstructor @RequiredArgsConstructor
@Service @Service
public class TEmpDisabilityInfoServiceImpl extends ServiceImpl<TEmpDisabilityInfoMapper, TEmpDisabilityInfo> implements TEmpDisabilityInfoService { public class TEmpDisabilityInfoServiceImpl extends ServiceImpl<TEmpDisabilityInfoMapper, TEmpDisabilityInfo> implements TEmpDisabilityInfoService {
...@@ -115,6 +121,14 @@ public class TEmpDisabilityInfoServiceImpl extends ServiceImpl<TEmpDisabilityInf ...@@ -115,6 +121,14 @@ public class TEmpDisabilityInfoServiceImpl extends ServiceImpl<TEmpDisabilityInf
} }
@Override @Override
public R<Boolean> saveDiy(TEmpDisabilityInfo tEmpDisabilityInfo) { public R<Boolean> saveDiy(TEmpDisabilityInfo tEmpDisabilityInfo) {
TEmpDisabilityInfo exist = baseMapper.selectOne(Wrappers.<TEmpDisabilityInfo>query().lambda()
.eq(TEmpDisabilityInfo::getEmpIdcard,tEmpDisabilityInfo.getEmpIdcard())
.eq(TEmpDisabilityInfo::getDisabilityName,tEmpDisabilityInfo.getDisabilityName())
.eq(TEmpDisabilityInfo::getDeleteFlag,CommonConstants.ZERO_STRING)
.last(CommonConstants.LAST_ONE_SQL));
if (Common.isNotNull(exist)){
return R.failed(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_DISABILITY_NAME_EXISTING));
}
tEmpDisabilityInfo.setDeleteFlag(CommonConstants.ZERO_STRING); tEmpDisabilityInfo.setDeleteFlag(CommonConstants.ZERO_STRING);
int res = baseMapper.insert(tEmpDisabilityInfo); int res = baseMapper.insert(tEmpDisabilityInfo);
if (res > CommonConstants.ZERO_INT){ if (res > CommonConstants.ZERO_INT){
...@@ -147,6 +161,80 @@ public class TEmpDisabilityInfoServiceImpl extends ServiceImpl<TEmpDisabilityInf ...@@ -147,6 +161,80 @@ public class TEmpDisabilityInfoServiceImpl extends ServiceImpl<TEmpDisabilityInf
return baseMapper.selectList(wrapper); return baseMapper.selectList(wrapper);
} }
@Override
public R<Boolean> updateByIdDiy(TEmpDisabilityInfo tEmpDisabilityInfo) {
TEmpDisabilityInfo exist = baseMapper.selectOne(Wrappers.<TEmpDisabilityInfo>query().lambda()
.eq(TEmpDisabilityInfo::getEmpIdcard,tEmpDisabilityInfo.getEmpIdcard())
.ne(TEmpDisabilityInfo::getId,tEmpDisabilityInfo.getId())
.eq(TEmpDisabilityInfo::getDisabilityName,tEmpDisabilityInfo.getDisabilityName())
.eq(TEmpDisabilityInfo::getDeleteFlag,CommonConstants.ZERO_STRING)
.last(CommonConstants.LAST_ONE_SQL));
if (Common.isNotNull(exist)){
R.failed(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_DISABILITY_NAME_EXISTING));
}
baseMapper.updateById(tEmpDisabilityInfo);
return R.ok();
}
@Override
public R<List<ErrorMessage>> importTmpDisabilityDiy(InputStream inputStream) {
List<ErrorMessage> errorMessageList = new ArrayList<>();
ExcelUtil<EmpDisabilityExcelVO> util1 = new ExcelUtil<>(EmpDisabilityExcelVO.class);;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try {
EasyExcel.read(inputStream, EmpDisabilityExcelVO.class, new ReadListener<EmpDisabilityExcelVO>() {
/**
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
/**
*临时存储
*/
private List<EmpDisabilityExcelVO> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@Override
public void invoke(EmpDisabilityExcelVO data, AnalysisContext context) {
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex+1);
ErrorMessage errorMessage = util1.checkEntity(data, data.getRowIndex());
if (Common.isNotNull(errorMessage)){
errorMessageList.add(errorMessage);
}else {
cachedDataList.add(data);
}
if (cachedDataList.size() >= BATCH_COUNT) {
saveData();
// 存储完成清理 list
cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
saveData();
}
/**
* 加上存储数据库
*/
private void saveData() {
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
importTmpDisability(cachedDataList,errorMessageList);
log.info("存储数据库成功!");
}
}).sheet().doRead();
}catch (Exception e){
log.error(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR,e);
return R.failed(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR);
}
return R.ok(errorMessageList);
}
private LambdaQueryWrapper buildQueryWrapper(DisabilitySearchVo entity){ private LambdaQueryWrapper buildQueryWrapper(DisabilitySearchVo entity){
LambdaQueryWrapper<TEmpDisabilityInfo> wrapper = Wrappers.lambdaQuery(); LambdaQueryWrapper<TEmpDisabilityInfo> wrapper = Wrappers.lambdaQuery();
wrapper.eq(TEmpDisabilityInfo::getDeleteFlag,CommonConstants.ZERO_STRING); wrapper.eq(TEmpDisabilityInfo::getDeleteFlag,CommonConstants.ZERO_STRING);
......
...@@ -18,6 +18,11 @@ package com.yifu.cloud.plus.v1.yifu.archives.service.impl; ...@@ -18,6 +18,11 @@ package com.yifu.cloud.plus.v1.yifu.archives.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ArrayUtil;
import com.alibaba.excel.EasyExcel;
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.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
...@@ -35,15 +40,15 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationUpdateExcelVo; ...@@ -35,15 +40,15 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationUpdateExcelVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationUpdateVO; import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationUpdateVO;
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.exception.ErrorCodes; import com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common; import com.yifu.cloud.plus.v1.yifu.common.core.util.*;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.MsgUtils;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity; import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
...@@ -52,6 +57,7 @@ import java.util.List; ...@@ -52,6 +57,7 @@ import java.util.List;
* @author fxj * @author fxj
* @date 2022-06-18 09:39:46 * @date 2022-06-18 09:39:46
*/ */
@Log4j2
@RequiredArgsConstructor @RequiredArgsConstructor
@Service @Service
public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, TEmpEducation> implements TEmpEducationService { public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, TEmpEducation> implements TEmpEducationService {
...@@ -157,30 +163,46 @@ public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, T ...@@ -157,30 +163,46 @@ public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, T
@Override @Override
public void importEmpEducationUpdate(List<EmpEducationUpdateExcelVo> excelVOList, List<ErrorMessage> errorMessageList) { public void importEmpEducationUpdate(List<EmpEducationUpdateExcelVo> excelVOList, List<ErrorMessage> errorMessageList) {
List<TEmpEducation> list = this.list(); List<TEmpEducation> list = this.list();
TEmployeeInfo emp; TEmpEducation temp;
TEmpEducation exist; TEmpEducation exist;
ErrorMessage errorMsg; ErrorMessage errorMsg;
// 执行数据插入操作 组装 // 执行数据插入操作 组装
for (int i = 0; i < excelVOList.size(); i++) { for (int i = 0; i < excelVOList.size(); i++) {
// 已有验证报错直接下一个 // 已有验证报错直接下一个
EmpEducationUpdateExcelVo excel = excelVOList.get(i); EmpEducationUpdateExcelVo excel = excelVOList.get(i);
temp = baseMapper.selectOne(Wrappers.<TEmpEducation>query().lambda()
.eq(TEmpEducation::getId,excel.getId())
.last(CommonConstants.LAST_ONE_SQL));
if (Common.isEmpty(temp)){
errorMessageList.add(new ErrorMessage(excel.getRowIndex(),CommonConstants.PARAM_IS_NOT_ERROR));
continue;
}
exist = baseMapper.selectOne(Wrappers.<TEmpEducation>query().lambda() exist = baseMapper.selectOne(Wrappers.<TEmpEducation>query().lambda()
.ne(TEmpEducation::getId,excel.getId())
.eq(TEmpEducation::getEmpIdcard,temp.getEmpIdcard())
.eq(TEmpEducation::getEducationName,excel.getEducationName()) .eq(TEmpEducation::getEducationName,excel.getEducationName())
.eq(TEmpEducation::getDeleteFlag,CommonConstants.ZERO_STRING) .eq(TEmpEducation::getDeleteFlag,CommonConstants.ZERO_STRING)
.last(CommonConstants.LAST_ONE_SQL)); .last(CommonConstants.LAST_ONE_SQL));
if (Common.isNotNull(exist)){ if (Common.isNotNull(exist)){
errorMessageList.add(new ErrorMessage(excel.getRowIndex(),MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_EDUCATION_EXISTING))); errorMessageList.add(new ErrorMessage(excel.getRowIndex(),MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_EDUCATION_EXISTING)));
continue;
} }
// 数据合法情况 // 数据合法情况
updateExcel(excel); updateExcel(excel,temp);
errorMessageList.add(new ErrorMessage(excel.getRowIndex(),CommonConstants.UPDATE_SUCCESS)); errorMessageList.add(new ErrorMessage(excel.getRowIndex(),CommonConstants.UPDATE_SUCCESS));
} }
} }
private void updateExcel(EmpEducationUpdateExcelVo excel) { private void updateExcel(EmpEducationUpdateExcelVo excel, TEmpEducation temp) {
TEmpEducation update = new TEmpEducation(); TEmpEducation update = new TEmpEducation();
BeanUtil.copyProperties(excel, update); BeanUtil.copyProperties(excel, update);
if (Common.isNotNull(temp)){
update.setEmpId(temp.getEmpId());
update.setEmpIdcard(temp.getEmpIdcard());
update.setEmpName(temp.getEmpName());
update.setEmpCode(temp.getEmpCode());
}
// 更新档案学历信息 // 更新档案学历信息
updateEducationOfEmp(update); updateEducationOfEmp(update);
this.updateById(update); this.updateById(update);
...@@ -213,6 +235,8 @@ public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, T ...@@ -213,6 +235,8 @@ public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, T
updateVo.setIsCollege(CommonConstants.ONE_INT); updateVo.setIsCollege(CommonConstants.ONE_INT);
} }
employeeInfoMapper.updateEducationOfEmp(updateVo); employeeInfoMapper.updateEducationOfEmp(updateVo);
// 所有学历更新为非最高学历
baseMapper.updateHighIdentification(education.getEmpIdcard());
} }
} }
...@@ -277,6 +301,123 @@ public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, T ...@@ -277,6 +301,123 @@ public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, T
} }
return baseMapper.selectList(wrapper); return baseMapper.selectList(wrapper);
} }
@Override
public R<List<ErrorMessage>> importEmpEducationDiy(InputStream inputStream) {
List<ErrorMessage> errorMessageList = new ArrayList<>();
ExcelUtil<EmpEducationExcelVO> util1 = new ExcelUtil<>(EmpEducationExcelVO.class);;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try {
EasyExcel.read(inputStream, EmpEducationExcelVO.class, new ReadListener<EmpEducationExcelVO>() {
/**
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
/**
*临时存储
*/
private List<EmpEducationExcelVO> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@Override
public void invoke(EmpEducationExcelVO data, AnalysisContext context) {
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex+1);
ErrorMessage errorMessage = util1.checkEntity(data, data.getRowIndex());
if (Common.isNotNull(errorMessage)){
errorMessageList.add(errorMessage);
}else {
cachedDataList.add(data);
}
if (cachedDataList.size() >= BATCH_COUNT) {
saveData();
// 存储完成清理 list
cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
saveData();
}
/**
* 加上存储数据库
*/
private void saveData() {
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
importEmpEducation(cachedDataList,errorMessageList);
log.info("存储数据库成功!");
}
}).sheet().doRead();
}catch (Exception e){
log.error(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR,e);
return R.failed(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR);
}
return R.ok(errorMessageList);
}
@Override
public R<List<ErrorMessage>> importEmpEducationUpdateDiy(InputStream inputStream) {
List<ErrorMessage> errorMessageList = new ArrayList<>();
ExcelUtil<EmpEducationUpdateExcelVo> util1 = new ExcelUtil<>(EmpEducationUpdateExcelVo.class);;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try {
EasyExcel.read(inputStream, EmpEducationUpdateExcelVo.class, new ReadListener<EmpEducationUpdateExcelVo>() {
/**
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
/**
*临时存储
*/
private List<EmpEducationUpdateExcelVo> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@Override
public void invoke(EmpEducationUpdateExcelVo data, AnalysisContext context) {
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex+1);
ErrorMessage errorMessage = util1.checkEntity(data, data.getRowIndex());
if (Common.isNotNull(errorMessage)){
errorMessageList.add(errorMessage);
}else {
cachedDataList.add(data);
}
if (cachedDataList.size() >= BATCH_COUNT) {
saveData();
// 存储完成清理 list
cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
saveData();
}
/**
* 加上存储数据库
*/
private void saveData() {
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
importEmpEducationUpdate(cachedDataList,errorMessageList);
log.info("存储数据库成功!");
}
}).sheet().doRead();
}catch (Exception e){
log.error(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR,e);
return R.failed(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR);
}
return R.ok(errorMessageList);
}
private LambdaQueryWrapper buildQueryWrapper(EducationSearchVo entity){ private LambdaQueryWrapper buildQueryWrapper(EducationSearchVo entity){
LambdaQueryWrapper<TEmpEducation> wrapper = Wrappers.lambdaQuery(); LambdaQueryWrapper<TEmpEducation> wrapper = Wrappers.lambdaQuery();
wrapper.eq(TEmpEducation::getDeleteFlag,CommonConstants.ZERO_STRING); wrapper.eq(TEmpEducation::getDeleteFlag,CommonConstants.ZERO_STRING);
......
...@@ -19,6 +19,11 @@ package com.yifu.cloud.plus.v1.yifu.archives.service.impl; ...@@ -19,6 +19,11 @@ package com.yifu.cloud.plus.v1.yifu.archives.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.EasyExcel;
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.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
...@@ -35,15 +40,15 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpFamilyExcelVO; ...@@ -35,15 +40,15 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpFamilyExcelVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.FamilySearchVO; import com.yifu.cloud.plus.v1.yifu.archives.vo.FamilySearchVO;
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.exception.ErrorCodes; import com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common; import com.yifu.cloud.plus.v1.yifu.common.core.util.*;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.MsgUtils;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity; import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
...@@ -52,6 +57,7 @@ import java.util.List; ...@@ -52,6 +57,7 @@ import java.util.List;
* @author fxj * @author fxj
* @date 2022-06-18 09:39:46 * @date 2022-06-18 09:39:46
*/ */
@Log4j2
@RequiredArgsConstructor @RequiredArgsConstructor
@Service @Service
public class TEmpFamilyServiceImpl extends ServiceImpl<TEmpFamilyMapper, TEmpFamily> implements TEmpFamilyService { public class TEmpFamilyServiceImpl extends ServiceImpl<TEmpFamilyMapper, TEmpFamily> implements TEmpFamilyService {
...@@ -161,6 +167,63 @@ public class TEmpFamilyServiceImpl extends ServiceImpl<TEmpFamilyMapper, TEmpFam ...@@ -161,6 +167,63 @@ public class TEmpFamilyServiceImpl extends ServiceImpl<TEmpFamilyMapper, TEmpFam
return baseMapper.selectList(wrapper); return baseMapper.selectList(wrapper);
} }
@Override
public R<List<ErrorMessage>> importEmpFamilyDiy(InputStream fileInputStream) {
List<ErrorMessage> errorMessageList = new ArrayList<>();
ExcelUtil<EmpFamilyExcelVO> util1 = new ExcelUtil<>(EmpFamilyExcelVO.class);;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try {
EasyExcel.read(fileInputStream, EmpFamilyExcelVO.class, new ReadListener<EmpFamilyExcelVO>() {
/**
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
/**
*临时存储
*/
private List<EmpFamilyExcelVO> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@Override
public void invoke(EmpFamilyExcelVO data, AnalysisContext context) {
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex+1);
ErrorMessage errorMessage = util1.checkEntity(data, data.getRowIndex());
if (Common.isNotNull(errorMessage)){
errorMessageList.add(errorMessage);
}else {
cachedDataList.add(data);
}
if (cachedDataList.size() >= BATCH_COUNT) {
saveData();
// 存储完成清理 list
cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
saveData();
}
/**
* 加上存储数据库
*/
private void saveData() {
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
importEmpFamily(cachedDataList,errorMessageList);
log.info("存储数据库成功!");
}
}).sheet().doRead();
}catch (Exception e){
log.error(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR,e);
return R.failed(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR);
}
return R.ok(errorMessageList);
}
private LambdaQueryWrapper buildQueryWrapper(FamilySearchVO entity){ private LambdaQueryWrapper buildQueryWrapper(FamilySearchVO entity){
LambdaQueryWrapper<TEmpFamily> wrapper = Wrappers.lambdaQuery(); LambdaQueryWrapper<TEmpFamily> wrapper = Wrappers.lambdaQuery();
wrapper.eq(TEmpFamily::getDeleteFlag,CommonConstants.ZERO_STRING); wrapper.eq(TEmpFamily::getDeleteFlag,CommonConstants.ZERO_STRING);
......
...@@ -18,6 +18,11 @@ package com.yifu.cloud.plus.v1.yifu.archives.service.impl; ...@@ -18,6 +18,11 @@ package com.yifu.cloud.plus.v1.yifu.archives.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ArrayUtil;
import com.alibaba.excel.EasyExcel;
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.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
...@@ -33,14 +38,14 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.CertifySearchVo; ...@@ -33,14 +38,14 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.CertifySearchVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpCertificateExcelVO; import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpCertificateExcelVO;
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.exception.ErrorCodes; import com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common; import com.yifu.cloud.plus.v1.yifu.common.core.util.*;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.MsgUtils;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity; import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
...@@ -49,6 +54,7 @@ import java.util.List; ...@@ -49,6 +54,7 @@ import java.util.List;
* @author fxj * @author fxj
* @date 2022-06-18 09:39:46 * @date 2022-06-18 09:39:46
*/ */
@Log4j2
@RequiredArgsConstructor @RequiredArgsConstructor
@Service @Service
public class TEmpProfessionalQualificationServiceImpl extends ServiceImpl<TEmpProfessionalQualificationMapper, TEmpProfessionalQualification> implements TEmpProfessionalQualificationService { public class TEmpProfessionalQualificationServiceImpl extends ServiceImpl<TEmpProfessionalQualificationMapper, TEmpProfessionalQualification> implements TEmpProfessionalQualificationService {
...@@ -151,6 +157,64 @@ public class TEmpProfessionalQualificationServiceImpl extends ServiceImpl<TEmpPr ...@@ -151,6 +157,64 @@ public class TEmpProfessionalQualificationServiceImpl extends ServiceImpl<TEmpPr
wrapper.orderByDesc(BaseEntity::getCreateTime); wrapper.orderByDesc(BaseEntity::getCreateTime);
return baseMapper.selectPage(page,wrapper); return baseMapper.selectPage(page,wrapper);
} }
@Override
public R<List<ErrorMessage>> importEmpCertificateDiy(InputStream inputStream) {
List<ErrorMessage> errorMessageList = new ArrayList<>();
ExcelUtil<EmpCertificateExcelVO> util1 = new ExcelUtil<>(EmpCertificateExcelVO.class);;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try {
EasyExcel.read(inputStream, EmpCertificateExcelVO.class, new ReadListener<EmpCertificateExcelVO>() {
/**
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
/**
*临时存储
*/
private List<EmpCertificateExcelVO> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@Override
public void invoke(EmpCertificateExcelVO data, AnalysisContext context) {
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex+1);
ErrorMessage errorMessage = util1.checkEntity(data, data.getRowIndex());
if (Common.isNotNull(errorMessage)){
errorMessageList.add(errorMessage);
}else {
cachedDataList.add(data);
}
if (cachedDataList.size() >= BATCH_COUNT) {
saveData();
// 存储完成清理 list
cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
saveData();
}
/**
* 加上存储数据库
*/
private void saveData() {
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
importEmpCertificate(cachedDataList,errorMessageList);
log.info("存储数据库成功!");
}
}).sheet().doRead();
}catch (Exception e){
log.error(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR,e);
return R.failed(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR);
}
return R.ok(errorMessageList);
}
private LambdaQueryWrapper buildQueryWrapper(CertifySearchVo entity){ private LambdaQueryWrapper buildQueryWrapper(CertifySearchVo entity){
LambdaQueryWrapper<TEmpProfessionalQualification> wrapper = Wrappers.lambdaQuery(); LambdaQueryWrapper<TEmpProfessionalQualification> wrapper = Wrappers.lambdaQuery();
wrapper.eq(TEmpProfessionalQualification::getDeleteFlag,CommonConstants.ZERO_STRING); wrapper.eq(TEmpProfessionalQualification::getDeleteFlag,CommonConstants.ZERO_STRING);
......
...@@ -19,6 +19,11 @@ package com.yifu.cloud.plus.v1.yifu.archives.service.impl; ...@@ -19,6 +19,11 @@ package com.yifu.cloud.plus.v1.yifu.archives.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.alibaba.excel.EasyExcel;
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.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
...@@ -34,14 +39,14 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpWorkRecordExcelVO; ...@@ -34,14 +39,14 @@ import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpWorkRecordExcelVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.WorkRecordSearchVO; import com.yifu.cloud.plus.v1.yifu.archives.vo.WorkRecordSearchVO;
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.exception.ErrorCodes; import com.yifu.cloud.plus.v1.yifu.common.core.exception.ErrorCodes;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common; import com.yifu.cloud.plus.v1.yifu.common.core.util.*;
import com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.common.core.util.MsgUtils;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity; import com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
...@@ -50,6 +55,7 @@ import java.util.List; ...@@ -50,6 +55,7 @@ import java.util.List;
* @author fxj * @author fxj
* @date 2022-06-18 09:39:46 * @date 2022-06-18 09:39:46
*/ */
@Log4j2
@RequiredArgsConstructor @RequiredArgsConstructor
@Service @Service
public class TEmpWorkRecordingServiceImpl extends ServiceImpl<TEmpWorkRecordingMapper, TEmpWorkRecording> implements TEmpWorkRecordingService { public class TEmpWorkRecordingServiceImpl extends ServiceImpl<TEmpWorkRecordingMapper, TEmpWorkRecording> implements TEmpWorkRecordingService {
...@@ -185,6 +191,64 @@ public class TEmpWorkRecordingServiceImpl extends ServiceImpl<TEmpWorkRecordingM ...@@ -185,6 +191,64 @@ public class TEmpWorkRecordingServiceImpl extends ServiceImpl<TEmpWorkRecordingM
return baseMapper.selectList(wrapper); return baseMapper.selectList(wrapper);
} }
@Override
public R<List<ErrorMessage>> importEmpWorkRecordDiy(InputStream inputStream) {
List<com.yifu.cloud.plus.v1.yifu.common.core.util.ErrorMessage> errorMessageList = new ArrayList<>();
ExcelUtil<EmpWorkRecordExcelVO> util1 = new ExcelUtil<>(EmpWorkRecordExcelVO.class);;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try {
EasyExcel.read(inputStream, EmpWorkRecordExcelVO.class, new ReadListener<EmpWorkRecordExcelVO>() {
/**
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = CommonConstants.BATCH_COUNT;
/**
*临时存储
*/
private List<EmpWorkRecordExcelVO> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@Override
public void invoke(EmpWorkRecordExcelVO data, AnalysisContext context) {
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex+1);
ErrorMessage errorMessage = util1.checkEntity(data, data.getRowIndex());
if (Common.isNotNull(errorMessage)){
errorMessageList.add(errorMessage);
}else {
cachedDataList.add(data);
}
if (cachedDataList.size() >= BATCH_COUNT) {
saveData();
// 存储完成清理 list
cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
}
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
saveData();
}
/**
* 加上存储数据库
*/
private void saveData() {
log.info("{}条数据,开始存储数据库!", cachedDataList.size());
importEmpWorkRecord(cachedDataList,errorMessageList);
log.info("存储数据库成功!");
}
}).sheet().doRead();
}catch (Exception e){
log.error(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR,e);
return R.failed(CommonConstants.IMPORT_DATA_ANALYSIS_ERROR);
}
return R.ok(errorMessageList);
}
private LambdaQueryWrapper buildQueryWrapper(WorkRecordSearchVO entity){ private LambdaQueryWrapper buildQueryWrapper(WorkRecordSearchVO entity){
LambdaQueryWrapper<TEmpWorkRecording> wrapper = Wrappers.lambdaQuery(); LambdaQueryWrapper<TEmpWorkRecording> wrapper = Wrappers.lambdaQuery();
wrapper.eq(TEmpWorkRecording::getDeleteFlag,CommonConstants.ZERO_STRING); wrapper.eq(TEmpWorkRecording::getDeleteFlag,CommonConstants.ZERO_STRING);
......
...@@ -572,6 +572,13 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap ...@@ -572,6 +572,13 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
//获取记录 //获取记录
list = gettEmpProInfoExportVos(idstr, projectDTO); list = gettEmpProInfoExportVos(idstr, projectDTO);
if (Common.isNotNull(list)){
ExcelUtil<EmployeeProjectExportVO> util = new ExcelUtil<>(EmployeeProjectExportVO.class);
for (EmployeeProjectExportVO vo:list){
util.convertEntity(vo,null,null,null);
}
}
ServletOutputStream out = null; ServletOutputStream out = null;
try { try {
if (list.size()>0) { if (list.size()>0) {
...@@ -580,7 +587,7 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap ...@@ -580,7 +587,7 @@ public class TEmployeeProjectServiceImpl extends ServiceImpl<TEmployeeProjectMap
response.setCharacterEncoding("utf-8"); response.setCharacterEncoding("utf-8");
response.setHeader("Content-Disposition", "attachment;filename*=utf-8'zh_cn'" + URLEncoder.encode(fileName , "UTF-8")); response.setHeader("Content-Disposition", "attachment;filename*=utf-8'zh_cn'" + URLEncoder.encode(fileName , "UTF-8"));
// 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭 // 这里 需要指定写用哪个class去写,然后写到第一个sheet,然后文件流会自动关闭
EasyExcel.write(fileName, EmployeeProjectExportVO.class).includeColumnFiledNames(includeColumnFiledNames).sheet("项目档案") EasyExcel.write(out, EmployeeProjectExportVO.class).includeColumnFiledNames(includeColumnFiledNames).sheet("项目档案")
.doWrite(list); .doWrite(list);
out.flush(); out.flush();
} }
......
...@@ -88,7 +88,9 @@ ...@@ -88,7 +88,9 @@
<result property="unitNo" column="UNIT_NO"/> <result property="unitNo" column="UNIT_NO"/>
<result property="deptName" column="DEPT_NAME"/> <result property="deptName" column="DEPT_NAME"/>
<result property="deptNo" column="DEPT_NO"/> <result property="deptNo" column="DEPT_NO"/>
<result property="businessType" column="BUSINESS_TYPE"/> <result property="businessPrimaryType" column="BUSINESS_PRIMARY_TYPE"/>
<result property="businessSecondType" column="BUSINESS_SECOND_TYPE"/>
<result property="businessThirdType" column="BUSINESS_THIRD_TYPE"/>
<result property="contractType" column="CONTRACT_TYPE"/> <result property="contractType" column="CONTRACT_TYPE"/>
<result property="workingHours" column="WORKING_HOURS"/> <result property="workingHours" column="WORKING_HOURS"/>
<result property="post" column="POST"/> <result property="post" column="POST"/>
...@@ -175,7 +177,9 @@ ...@@ -175,7 +177,9 @@
a.UNIT_NO, a.UNIT_NO,
a.DEPT_NAME, a.DEPT_NAME,
a.DEPT_NO, a.DEPT_NO,
concat(a.BUSINESS_PRIMARY_TYPE,'/',BUSINESS_SECOND_TYPE,'/',a.BUSINESS_THIRD_TYPE) AS BUSINESS_TYPE, a.BUSINESS_PRIMARY_TYPE,
a.BUSINESS_SECOND_TYPE,
a.BUSINESS_THIRD_TYPE,
a.CONTRACT_TYPE, a.CONTRACT_TYPE,
a.WORKING_HOURS, a.WORKING_HOURS,
a.POST, a.POST,
...@@ -462,9 +466,9 @@ ...@@ -462,9 +466,9 @@
<if test="tEmployeeProject.fileTown != null"> <if test="tEmployeeProject.fileTown != null">
AND b.FILE_TOWN = #{tEmployeeProject.fileTown} AND b.FILE_TOWN = #{tEmployeeProject.fileTown}
</if> </if>
<if test="tEmployeeInfo.idList != null"> <if test="tEmployeeProject.idList != null">
AND a.id in AND a.id in
<foreach item="idStr" index="index" collection="tEmployeeInfo.idList" open="(" separator="," close=")"> <foreach item="idStr" index="index" collection="tEmployeeProject.idList" open="(" separator="," close=")">
#{idStr} #{idStr}
</foreach> </foreach>
</if> </if>
......
...@@ -255,4 +255,5 @@ public interface CommonConstants { ...@@ -255,4 +255,5 @@ public interface CommonConstants {
String IMPORT_DATA_ANALYSIS_ERROR = "数据导入解析异常,请检查表数据格式"; String IMPORT_DATA_ANALYSIS_ERROR = "数据导入解析异常,请检查表数据格式";
String CREATE_TIME = "create_time"; String CREATE_TIME = "create_time";
String ID = "ID"; String ID = "ID";
String PARAM_IS_NOT_ERROR = "传参异常,请检查参数";
} }
...@@ -153,7 +153,7 @@ public @interface ExcelAttribute { ...@@ -153,7 +153,7 @@ public @interface ExcelAttribute {
* 日期格式化字符串 * 日期格式化字符串
* @return * @return
*/ */
public abstract String dateFormat() default "YYYY-MM-dd"; public abstract String dateFormat() default "yyyy-MM-dd";
/** /**
* 日期格式化字符串 * 日期格式化字符串
......
...@@ -13,10 +13,7 @@ import java.math.BigDecimal; ...@@ -13,10 +13,7 @@ import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Date; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* @Author fxj * @Author fxj
...@@ -41,6 +38,155 @@ public class ExcelUtil <T> implements Serializable { ...@@ -41,6 +38,155 @@ public class ExcelUtil <T> implements Serializable {
} }
private Field[] fields; private Field[] fields;
public void convertEntity(T vo, String[] exportFields, Map<String,String> diyDicMap, String dateFormat) {
// 得到所有定义字段
Field[] allFields = clazz.getDeclaredFields();
List<Field> fields = new ArrayList<Field>();
Class<?> superClazz = clazz.getSuperclass();
// 得到所有field并存放到一个list中
for (Field field : allFields) {
if (field.isAnnotationPresent(ExcelAttribute.class)) {
fields.add(field);
}
}
if (superClazz != null) {
Field[] superFields = superClazz.getDeclaredFields();
for (Field field : superFields) {
if (field.isAnnotationPresent(ExcelAttribute.class)) {
fields.add(field);
}
}
}
fields = getFiledsByParamFiled(fields, exportFields);
ExcelAttribute attr;
Field field;
//分割符
String divider;
for (int j = 0; j < fields.size(); j++) {
// 获得field
field = fields.get(j);
// 设置实体类私有属性可访问
field.setAccessible(true);
attr = field.getAnnotation(ExcelAttribute.class);
if (attr.isExport()) {
// 如果数据存在就填入,不存在填入空格
Class<?> classType = field.getType();
String value = null;
Date date;
try {
if (field.get(vo) != null && (classType.isAssignableFrom(Date.class) || classType.isAssignableFrom(LocalDateTime.class) || classType.isAssignableFrom(LocalDate.class))) {
if (Common.isNotNull(attr.dateFormatExport())) {
date = DateUtil.stringToDate2(String.valueOf(field.get(vo)), attr.dateFormatExport());
if (classType.isAssignableFrom(LocalDateTime.class)){
value = LocalDateTimeUtils.formatTime((LocalDateTime)field.get(vo),attr.dateFormatExport());
}else {
value = DateUtil.dateToString(date, attr.dateFormatExport());
}
} else {
date = DateUtil.stringToDate2(String.valueOf(field.get(vo)), !Common.isNotNull(dateFormat) ? DateUtil.ISO_EXPANDED_DATE_FORMAT : dateFormat);
if (classType.isAssignableFrom(LocalDateTime.class)){
value = LocalDateTimeUtils.formatTime((LocalDateTime)field.get(vo),!Common.isNotNull(dateFormat) ? DateUtil.ISO_EXPANDED_DATE_FORMAT : dateFormat);
}else {
value = cn.hutool.core.date.DateUtil.format(date, !Common.isNotNull(dateFormat) ? DateUtil.ISO_EXPANDED_DATE_FORMAT : dateFormat);
}
}
}
//如果有默认字典数据直接取值
if (Common.isNotNull(attr.readConverterExp())) {
value = convertByExp(field.get(vo) == null ? "" : String.valueOf(field.get(vo)), attr.readConverterExp());
} else if (attr.isDataId()) {
//加入分割符逻辑
divider = attr.divider();
if(!"".equals(divider) && field.get(vo) != null) {
//如果是字典数据ID或区域ID 去dicMap(包含了区域) 取值 取不到返回空
value = getLableById(attr, diyDicMap, field.get(vo) == null ? "" : String.valueOf(field.get(vo)));
}
} else if (attr.isArea()){
//区域字段处理 TODO
if (!Common.isNotNull(attr.parentField())) {
value = getAreaLabel("area_"+field.get(vo) + "_0", attr);
} else {
// TODO
value = getAreaLabel("area_"+field.get(vo)+ "_" + getFieldValueByName(attr.parentField(), vo, null), attr);
}
}
field.set(vo, Common.isNotNull(value)?value:field.get(vo));
}catch (Exception e){
log.error("字典数据解析异常");
}
}
}
}
/**
* 通过标志_字典ID的方式去dicMap 取值
*
* @param attr
* @param dicMap 字典值 key: 类型标识_ID value:实际要导出的内容
* @param value 对应字段的ID值
* @return
* @Author fxj
* @Date 2019-08-06
**/
private String getLableById(ExcelAttribute attr, Map<String, String> dicMap, String value) {
String tempValue = null;
if (null != dicMap && dicMap.size() > 0 && Common.isNotNull(value)) {
if (Common.isNotNull(attr.dataType())) {
tempValue = dicMap.get(attr.dataType() + CommonConstants.DOWN_LINE_STRING + value);
if (Common.isEmpty(tempValue)){
tempValue = dicMap.get(attr.dataType() + CommonConstants.DOWN_LINE_STRING +"id"+CommonConstants.DOWN_LINE_STRING + value);
}
} else {
tempValue = dicMap.get(value);
}
}
// 默认字典获取不到 去 缓存获取
if (Common.isEmpty(tempValue)){
Map<String,String> dicObj = (Map<String, String>) RedisUtil.redis.opsForValue().get(attr.dataType());
boolean flag = true;
for (Map.Entry<String,String> entry:dicObj.entrySet()){
if (Common.isNotNull(entry.getKey()) && entry.getKey().equals(value.trim())){
tempValue = entry.getValue();
break;
}
}
}
return tempValue;
}
/**
* 返回传参对应的fileds
*
* @param fields
* @param paramFields
* @return
* @Author fxj
* @Date 2019-08-05
**/
private List<Field> getFiledsByParamFiled(List<Field> fields, String[] paramFields) {
List<Field> fieldsTemp = new ArrayList<Field>();
List<String> attrName = new ArrayList();//存中文名 wangan修改
if (null != paramFields && paramFields.length > 0) {
ExcelAttribute attr;
Field field;
for (int j = 0; j < paramFields.length; j++) {
for (int i = 0; i < fields.size(); i++) {
field = fields.get(i);
attr = field.getAnnotation(ExcelAttribute.class);
//如果有同样的中文名数据字段,后面不再添加。 wangan修改
if (!attrName.contains(attr.name())) {
if (attr.name().equals(paramFields[j])) {
fieldsTemp.add(field);
attrName.add(attr.name());
break;
}
}
}
}
} else {
return fields;
}
return fieldsTemp;
}
public ErrorMessage checkEntity(T data , Integer rowNum) { public ErrorMessage checkEntity(T data , Integer rowNum) {
if (!Common.isNotNull(fields)){ if (!Common.isNotNull(fields)){
return null; return null;
...@@ -85,7 +231,7 @@ public class ExcelUtil <T> implements Serializable { ...@@ -85,7 +231,7 @@ public class ExcelUtil <T> implements Serializable {
//如果是需要从字典表取值数据的话在这里处理即可 //如果是需要从字典表取值数据的话在这里处理即可
if (Common.isNotNull(attr.readConverterExp())) { if (Common.isNotNull(attr.readConverterExp())) {
tempStr = reverseByExp( c, attr.readConverterExp()); c = reverseByExp( c, attr.readConverterExp());
} else if (attr.isDataId()) { } else if (attr.isDataId()) {
if (Common.isNotNull(attr.dataType())) { if (Common.isNotNull(attr.dataType())) {
//非区域字段处理 TODO //非区域字段处理 TODO
...@@ -100,7 +246,7 @@ public class ExcelUtil <T> implements Serializable { ...@@ -100,7 +246,7 @@ public class ExcelUtil <T> implements Serializable {
if (attr.isArea()) { if (attr.isArea()) {
//区域字段处理 TODO //区域字段处理 TODO
if (!Common.isNotNull(attr.parentField())) { if (!Common.isNotNull(attr.parentField())) {
tempStr = getDicValue("area_"+c.trim() + "_0", tempStr, attr,rowNum,errorTemp); tempStr = getDicValue("area_"+c.trim(), tempStr, attr,rowNum,errorTemp);
} else { } else {
// TODO // TODO
tempStr = getDicValue("area_"+c.trim()+ "_" + getFieldValueByName(attr.parentField(), data, DateUtil.ISO_EXPANDED_DATE_FORMAT), tempStr, attr,rowNum,errorTemp); tempStr = getDicValue("area_"+c.trim()+ "_" + getFieldValueByName(attr.parentField(), data, DateUtil.ISO_EXPANDED_DATE_FORMAT), tempStr, attr,rowNum,errorTemp);
...@@ -124,7 +270,8 @@ public class ExcelUtil <T> implements Serializable { ...@@ -124,7 +270,8 @@ public class ExcelUtil <T> implements Serializable {
} }
} }
continue; continue;
} else { }
if (Common.isNotNull(tempStr)){
c = tempStr; c = tempStr;
} }
} }
...@@ -139,7 +286,7 @@ public class ExcelUtil <T> implements Serializable { ...@@ -139,7 +286,7 @@ public class ExcelUtil <T> implements Serializable {
c = c.indexOf('%') != -1 ? c.replace("%", "") : c; c = c.indexOf('%') != -1 ? c.replace("%", "") : c;
field.set(data, BigDecimal.valueOf(Double.valueOf(c))); field.set(data, BigDecimal.valueOf(Double.valueOf(c)));
} else if (Date.class == fieldType && Common.isNotNull(c.trim())) { } else if (Date.class == fieldType && Common.isNotNull(c.trim())) {
field.set(data, DateUtil.stringToDate(c.trim(), Common.isEmpty(attr.dateFormat()) ? DateUtil.ISO_EXPANDED_DATE_FORMAT : attr.dateFormat())); field.set(data, DateUtil.parseDate(c.trim(), Common.isEmpty(attr.dateFormat()) ? DateUtil.ISO_EXPANDED_DATE_FORMAT : attr.dateFormat()));
} else if ((Integer.TYPE == fieldType) || (Integer.class == fieldType)) { } else if ((Integer.TYPE == fieldType) || (Integer.class == fieldType)) {
field.set(data, Integer.parseInt(c)); field.set(data, Integer.parseInt(c));
} else if ((Long.TYPE == fieldType) || (Long.class == fieldType)) { } else if ((Long.TYPE == fieldType) || (Long.class == fieldType)) {
...@@ -194,7 +341,7 @@ public class ExcelUtil <T> implements Serializable { ...@@ -194,7 +341,7 @@ public class ExcelUtil <T> implements Serializable {
return errorMessageHashMap.get(rowNum); return errorMessageHashMap.get(rowNum);
} }
/** /**
* 例如:解析值 0=男,1=女,2=未知 * 例如:解析值 0=男,1=女,2=未知 传参 男解析为 0
* *
* @param propertyValue 参数值 * @param propertyValue 参数值
* @param converterExp 翻译注解 * @param converterExp 翻译注解
...@@ -202,6 +349,46 @@ public class ExcelUtil <T> implements Serializable { ...@@ -202,6 +349,46 @@ public class ExcelUtil <T> implements Serializable {
* @throws Exception * @throws Exception
*/ */
public static String reverseByExp(String propertyValue, String converterExp) throws Exception { public static String reverseByExp(String propertyValue, String converterExp) throws Exception {
try {
String[] convertSource = converterExp.split(",");
if(propertyValue.contains(",")){
String[] valueSource = propertyValue.split(",");
propertyValue = "";
for(String value:valueSource){
for (String item : convertSource) {
String[] itemArray = item.split("=");
if (itemArray[1].equals(value)) {
propertyValue += itemArray[0] + ",";
break;
}
}
}
if(propertyValue.endsWith(",")){
propertyValue = propertyValue.substring(CommonConstants.dingleDigitIntArray[0],propertyValue.length()-1);
}
}else{
for (String item : convertSource) {
String[] itemArray = item.split("=");
if (itemArray[1].equals(propertyValue)) {
return itemArray[0];
}
}
}
} catch (Exception e) {
throw e;
}
return propertyValue;
}
/**
* 例如:解析值 0=男,1=女,2=未知 传参 0解析为 男
*
* @param propertyValue 参数值
* @param converterExp 翻译注解
* @return 解析后值
* @throws Exception
*/
public static String convertByExp(String propertyValue, String converterExp) throws Exception {
try { try {
String[] convertSource = converterExp.split(","); String[] convertSource = converterExp.split(",");
if(propertyValue.contains(",")){ if(propertyValue.contains(",")){
...@@ -232,6 +419,15 @@ public class ExcelUtil <T> implements Serializable { ...@@ -232,6 +419,15 @@ public class ExcelUtil <T> implements Serializable {
} }
return propertyValue; return propertyValue;
} }
private String getAreaLabel(String c, ExcelAttribute attr) {
Map<String,String> dicObj = (Map<String, String>) RedisUtil.redis.opsForValue().get(attr.dataType());
for (Map.Entry<String,String> entry:dicObj.entrySet()){
if (Common.isNotNull(entry.getValue()) && entry.getValue().equals(c.trim())){
return entry.getKey();
}
}
return null;
}
private String getDicValue(String c, String tempStr, ExcelAttribute attr,Integer rowNum, ErrorMessage errorTemp) { private String getDicValue(String c, String tempStr, ExcelAttribute attr,Integer rowNum, ErrorMessage errorTemp) {
Map<String,String> dicObj = (Map<String, String>) RedisUtil.redis.opsForValue().get(attr.dataType()); Map<String,String> dicObj = (Map<String, String>) RedisUtil.redis.opsForValue().get(attr.dataType());
boolean flag = true; boolean flag = true;
......
...@@ -39,14 +39,14 @@ sys.role.update.error.code.exist="\u5DF2\u5B58\u5728\u5BF9\u5E94\u6807\u8BC6\u76 ...@@ -39,14 +39,14 @@ sys.role.update.error.code.exist="\u5DF2\u5B58\u5728\u5BF9\u5E94\u6807\u8BC6\u76
sys.role.delete.existing.user=\u8BE5\u89D2\u8272\u4E0B\u8FD8\u6709\u5173\u8054\u7684\u7528\u6237\uFF0C\u8BF7\u5148\u5C06\u7528\u6237\u8F6C\u79FB\u5230\u5176\u4ED6\u89D2\u8272! sys.role.delete.existing.user=\u8BE5\u89D2\u8272\u4E0B\u8FD8\u6709\u5173\u8054\u7684\u7528\u6237\uFF0C\u8BF7\u5148\u5C06\u7528\u6237\u8F6C\u79FB\u5230\u5176\u4ED6\u89D2\u8272!
archives.emp.disability.name.existing=\u5DF2\u5B58\u5728\u5BF9\u5E94\u4F24\u6B8B\u75C5\u540D\u79F0\u7684\u6570\u636E archives.emp.disability.name.existing=\u8BE5\u5458\u5DE5\u5DF2\u5B58\u5728\u5BF9\u5E94\u4F24\u6B8B\u75C5\u540D\u79F0\u7684\u6570\u636E
archives.emp.family.name.existing=\u5DF2\u5B58\u5728\u5BF9\u5E94\u8EAB\u4EFD\u8BC1\u7684\u5BB6\u5EAD\u6210\u5458\u4FE1\u606F archives.emp.family.name.existing=\u8BE5\u5458\u5DE5\u5DF2\u5B58\u5728\u5BF9\u5E94\u8EAB\u4EFD\u8BC1\u7684\u5BB6\u5EAD\u6210\u5458\u4FE1\u606F
archives.emp.not.exist=\u65E0\u5BF9\u5E94\u8EAB\u4EFD\u8BC1\u7684\u5458\u5DE5\u4FE1\u606F archives.emp.not.exist=\u65E0\u5BF9\u5E94\u8EAB\u4EFD\u8BC1\u7684\u5458\u5DE5\u4FE1\u606F
archives.emp.reduced=\u5458\u5DE5\u5DF2\u51CF\u6863 archives.emp.reduced=\u5458\u5DE5\u5DF2\u51CF\u6863
archives.emp.work.record.existing=\u5DF2\u5B58\u5728\u5BF9\u5E94\u8EAB\u4EFD\u8BC1\u7684\u5DE5\u4F5C\u8BB0\u5F55\u4FE1\u606F archives.emp.work.record.existing=\u8BE5\u5458\u5DE5\u5DF2\u5B58\u5728\u5BF9\u5E94\u8EAB\u4EFD\u8BC1\u7684\u5DE5\u4F5C\u8BB0\u5F55\u4FE1\u606F
archives.emp.education.existing=\u5DF2\u5B58\u5728\u8BE5\u5458\u5DE5\u5BF9\u5E94\u5B66\u5386\u540D\u79F0\u7684\u5B66\u5386\u4FE1\u606F archives.emp.education.existing=\u8BE5\u5458\u5DE5\u5DF2\u5B58\u5728\u8BE5\u5458\u5DE5\u5BF9\u5E94\u5B66\u5386\u540D\u79F0\u7684\u5B66\u5386\u4FE1\u606F
param.not.empty=\u53C2\u6570\u4E0D\u53EF\u4E3A\u7A7A param.not.empty=\u53C2\u6570\u4E0D\u53EF\u4E3A\u7A7A
......
...@@ -311,7 +311,7 @@ public class DictController { ...@@ -311,7 +311,7 @@ public class DictController {
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.Map < java.lang.String, java.util.Map < java.lang.String, java.lang.String>>> * @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<java.util.Map < java.lang.String, java.util.Map < java.lang.String, java.lang.String>>>
**/ **/
@Inner @Inner
@GetMapping("/inner/getDictToLable") @PostMapping("/inner/getDictToLable")
public R<Map<String, Map<String, String>>> getDictToLable() { public R<Map<String, Map<String, String>>> getDictToLable() {
return sysDictItemService.getDictToLable(); return sysDictItemService.getDictToLable();
} }
......
...@@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -46,10 +47,23 @@ public class DictItemRedisInit { ...@@ -46,10 +47,23 @@ public class DictItemRedisInit {
log.info("区域数据加入缓存初始化开始..."); log.info("区域数据加入缓存初始化开始...");
List<SysArea> allAreas = sysAreaService.getAllArea(); List<SysArea> allAreas = sysAreaService.getAllArea();
if (Common.isNotNull(allAreas)){ if (Common.isNotNull(allAreas)){
Map<String,SysArea> areaMap = new HashMap<>();
for (SysArea area:allAreas){ for (SysArea area:allAreas){
redisUtil.set("area_" + area.getId() redisUtil.set("area_" + area.getId()
+ CommonConstants.DOWN_LINE_STRING + CommonConstants.DOWN_LINE_STRING
+(Common.isEmpty(area.getParentId())?"0":area.getParentId()),area.getId()); +(Common.isEmpty(area.getParentId())?"0":area.getParentId()),area.getAreaName());
areaMap.put(area.getId().toString(),area);
}
SysArea temp;
for (SysArea area:allAreas){
if (Common.isNotNull(area.getParentId()) && area.getParentId().intValue() > 0){
temp = areaMap.get(area.getParentId());
redisUtil.set("area_" + area.getAreaName()
+ CommonConstants.DOWN_LINE_STRING
+(Common.isNotNull(temp)?temp.getAreaName():""),area.getId());
}else {
redisUtil.set("area_" + area.getAreaName(),area.getId());
}
} }
} }
log.info("区域数据加入缓存初始化结束..."); log.info("区域数据加入缓存初始化结束...");
......
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