Commit 71d52d2c authored by fangxinjiang's avatar fangxinjiang

excel导入导出组件

parent 0aaf43f5
...@@ -36,5 +36,9 @@ ...@@ -36,5 +36,9 @@
<groupId>com.pig4cloud.excel</groupId> <groupId>com.pig4cloud.excel</groupId>
<artifactId>excel-spring-boot-starter</artifactId> <artifactId>excel-spring-boot-starter</artifactId>
</dependency> </dependency>
</dependencies> <dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
</dependencies>
</project> </project>
package com.yifu.cloud.plus.v1.yifu.archives.util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
/**
* @Author fxj
* @Date 2022/6/22
* @Description
* @Version 1.0
*/
@Component
public class RedisUtil {
@Autowired
private static RedisTemplate redisTemplate;
}
package com.yifu.cloud.plus.v1.yifu.archives.vo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpProfessionalQualification;
import lombok.Data;
/**
* @Author fxj
* @Date 2022/6/23
* @Description
* @Version 1.0
*/
@Data
public class CertifySearchVo extends TEmpProfessionalQualification {
private String ids;
}
package com.yifu.cloud.plus.v1.yifu.archives.vo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpDisabilityInfo;
import lombok.Data;
/**
* @Author fxj
* @Date 2022/6/23
* @Description
* @Version 1.0
*/
@Data
public class DisabilitySearchVo extends TEmpDisabilityInfo {
private String ids;
}
package com.yifu.cloud.plus.v1.yifu.archives.vo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpEducation;
import lombok.Data;
/**
* @Author fxj
* @Date 2022/6/23
* @Description
* @Version 1.0
*/
@Data
public class EducationSearchVo extends TEmpEducation {
private String ids;
}
...@@ -28,7 +28,7 @@ public class EmpCertificateExcelVO implements Serializable { ...@@ -28,7 +28,7 @@ public class EmpCertificateExcelVO implements Serializable {
* 员工身份证 * 员工身份证
*/ */
@NotNull(message = "员工身份证不可为空") @NotNull(message = "员工身份证不可为空")
@ExcelProperty(value ="员工身份证") @ExcelProperty(value ="身份证号")
private String empIdcard; private String empIdcard;
/** /**
......
...@@ -13,6 +13,7 @@ import javax.validation.constraints.Past; ...@@ -13,6 +13,7 @@ import javax.validation.constraints.Past;
import javax.validation.constraints.Pattern; import javax.validation.constraints.Pattern;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Date;
/** /**
* 员工伤残excel 对应的实体 * 员工伤残excel 对应的实体
...@@ -30,7 +31,7 @@ public class EmpDisabilityExcelVO implements Serializable { ...@@ -30,7 +31,7 @@ public class EmpDisabilityExcelVO implements Serializable {
* 员工身份证 * 员工身份证
*/ */
@NotNull(message = "员工身份证不能为空") @NotNull(message = "员工身份证不能为空")
@ExcelProperty(value ="员工身份证") @ExcelProperty(value ="身份证号")
private String empIdcard; private String empIdcard;
/** /**
* 员工姓名 * 员工姓名
...@@ -45,6 +46,12 @@ public class EmpDisabilityExcelVO implements Serializable { ...@@ -45,6 +46,12 @@ public class EmpDisabilityExcelVO implements Serializable {
@ExcelProperty(value ="伤残病名称") @ExcelProperty(value ="伤残病名称")
private String disabilityName; private String disabilityName;
/**
* 职业病名称
*/
@ExcelProperty(value ="职业病名称")
private String occupationalDisease;
/** /**
* 伤残等级 * 伤残等级
*/ */
...@@ -52,13 +59,6 @@ public class EmpDisabilityExcelVO implements Serializable { ...@@ -52,13 +59,6 @@ public class EmpDisabilityExcelVO implements Serializable {
@ExcelProperty(value ="伤残等级") @ExcelProperty(value ="伤残等级")
private String disabilityLevel; private String disabilityLevel;
/**
* 是否工伤标识0是/1否
*/
@NotNull(message = "是否工伤标识(0是/1否)不能为空")
@ExcelProperty(value ="是否工伤")
private String injuryIdentification;
/** /**
* 伤残开始日期 * 伤残开始日期
*/ */
...@@ -66,7 +66,7 @@ public class EmpDisabilityExcelVO implements Serializable { ...@@ -66,7 +66,7 @@ public class EmpDisabilityExcelVO implements Serializable {
@Past @Past
@DateTimeFormat("YYYY-MM-dd") @DateTimeFormat("YYYY-MM-dd")
@ExcelProperty(value ="伤残开始日期") @ExcelProperty(value ="伤残开始日期")
private LocalDateTime startTime; private Date startTime;
/** /**
* 伤残结束日期 * 伤残结束日期
...@@ -75,13 +75,14 @@ public class EmpDisabilityExcelVO implements Serializable { ...@@ -75,13 +75,14 @@ public class EmpDisabilityExcelVO implements Serializable {
@Past @Past
@DateTimeFormat("YYYY-MM-dd") @DateTimeFormat("YYYY-MM-dd")
@ExcelProperty(value ="伤残结束日期") @ExcelProperty(value ="伤残结束日期")
private LocalDateTime endTime; private Date endTime;
/** /**
* 职业病名称 * 是否工伤标识0是/1否
*/ */
@ExcelProperty(value ="职业病名称") @NotNull(message = "是否工伤标识(0是/1否)不能为空")
private String occupationalDisease; @ExcelProperty(value ="是否工伤")
private String injuryIdentification;
/** /**
* 备注 * 备注
......
...@@ -8,6 +8,7 @@ import lombok.Data; ...@@ -8,6 +8,7 @@ import lombok.Data;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Date;
/** /**
* 员工伤残excel 对应的实体 * 员工伤残excel 对应的实体
...@@ -32,25 +33,28 @@ public class EmpEducationExcelVO implements Serializable { ...@@ -32,25 +33,28 @@ public class EmpEducationExcelVO implements Serializable {
* 身份证号 * 身份证号
*/ */
@NotNull(message = "员工身份证不可为空") @NotNull(message = "员工身份证不可为空")
@ExcelProperty(value ="员工身份证") @ExcelProperty(value ="身份证号")
private String empIdcard; private String empIdcard;
/**
* 学校名称
*/
@NotNull(message = "学校不可为空")
@ExcelProperty(value ="学校")
private String school;
/** /**
* 入学时间 * 院系名称
*/ */
@NotNull(message = "入学时间不可为空") @ExcelProperty(value ="院系名称")
@DateTimeFormat("YYYY-MM-dd") private String collageSystem;
@ExcelProperty(value ="入学时间")
private LocalDateTime entryDate;
/** /**
* 结业日期 * 专业
*/ */
@NotNull(message = "毕业时间不可为空") @NotNull(message = "专业不可为空")
@DateTimeFormat("YYYY-MM-dd") @ExcelProperty(value ="专业")
@ExcelProperty(value ="毕业时间") private String major;
private LocalDateTime gradutionDate;
/** /**
* 学历名称 * 学历名称
...@@ -60,42 +64,39 @@ public class EmpEducationExcelVO implements Serializable { ...@@ -60,42 +64,39 @@ public class EmpEducationExcelVO implements Serializable {
private String educationName; private String educationName;
/** /**
* 学校名称 * 学历类型:全日制、自考、函授等
*/ */
@NotNull(message = "学校不可为空") @ExcelProperty(value ="学历类型")
@ExcelProperty(value ="学校") private String type;
private String school;
/** /**
* 专业 * 最高学历标识0是/1否
*/ */
@ExcelProperty(value ="专业") @NotNull(message = "最高学历标识不可为空")
private String major; @ExcelProperty(value ="最高学历")
private String highIdentification;
/** /**
* 学制类型:四年、三年、五年、二年 * 学制类型:四年、三年、五年、二年
*/ */
@ExcelProperty(value ="学制") @ExcelProperty(value ="学制类型")
private String educationSystem; private String educationSystem;
/** /**
* 最高学历标识0是/1否 * 入学时间
*/
@NotNull(message = "最高学历标识不可为空")
@ExcelProperty(value ="最高学历标识")
private String highIdentification;
/**
* 学历类型:全日制、自考、函授等
*/ */
@ExcelProperty(value ="学历类型") @NotNull(message = "入学时间不可为空")
private String type; @DateTimeFormat("YYYY-MM-dd")
@ExcelProperty(value ="入学时间")
private Date entryDate;
/** /**
* 院系名称 * 结业日期
*/ */
@ExcelProperty(value ="院系") @NotNull(message = "毕业时间不可为空")
private String collageSystem; @DateTimeFormat("YYYY-MM-dd")
@ExcelProperty(value ="毕业时间")
private Date gradutionDate;
/** /**
* 证书名称 * 证书名称
......
...@@ -5,7 +5,7 @@ import com.alibaba.excel.annotation.format.DateTimeFormat; ...@@ -5,7 +5,7 @@ import com.alibaba.excel.annotation.format.DateTimeFormat;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.time.LocalDateTime; import java.util.Date;
/** /**
* @Author fxj * @Author fxj
...@@ -14,7 +14,7 @@ import java.time.LocalDateTime; ...@@ -14,7 +14,7 @@ import java.time.LocalDateTime;
* @Version 1.0 * @Version 1.0
*/ */
@Data @Data
public class EmpEducationUpdateExcelVo extends EmpEducationExcelVO{ public class EmpEducationUpdateExcelVo{
/** /**
* @Author fxj * @Author fxj
* @Description 主键 * @Description 主键
...@@ -24,20 +24,25 @@ public class EmpEducationUpdateExcelVo extends EmpEducationExcelVO{ ...@@ -24,20 +24,25 @@ public class EmpEducationUpdateExcelVo extends EmpEducationExcelVO{
private String id; private String id;
/** /**
* 入学时间 * 学校名称
*/ */
@NotNull(message = "入学时间不可为空") @NotNull(message = "学校不可为空")
@DateTimeFormat("YYYY-MM-dd") @ExcelProperty(value ="学校")
@ExcelProperty(value ="入学时间") private String school;
private LocalDateTime entryDate;
/** /**
* 结业日期 * 院系名称
*/ */
@NotNull(message = "毕业时间不可为空") @ExcelProperty(value ="院系名称")
@DateTimeFormat("YYYY-MM-dd") private String collageSystem;
@ExcelProperty(value ="毕业时间")
private LocalDateTime gradutionDate;
/**
* 专业
*/
@NotNull(message = "专业不可为空")
@ExcelProperty(value ="专业")
private String major;
/** /**
* 学历名称 * 学历名称
...@@ -47,42 +52,39 @@ public class EmpEducationUpdateExcelVo extends EmpEducationExcelVO{ ...@@ -47,42 +52,39 @@ public class EmpEducationUpdateExcelVo extends EmpEducationExcelVO{
private String educationName; private String educationName;
/** /**
* 学校名称 * 学历类型:全日制、自考、函授等
*/ */
@NotNull(message = "学校不可为空") @ExcelProperty(value ="学历类型")
@ExcelProperty(value ="学校") private String type;
private String school;
/** /**
* 专业 * 最高学历标识0是/1否
*/ */
@ExcelProperty(value ="专业") @NotNull(message = "最高学历标识不可为空")
private String major; @ExcelProperty(value ="最高学历")
private String highIdentification;
/** /**
* 学制类型:四年、三年、五年、二年 * 学制类型:四年、三年、五年、二年
*/ */
@ExcelProperty(value ="学制") @ExcelProperty(value ="学制类型")
private String educationSystem; private String educationSystem;
/** /**
* 最高学历标识0是/1否 * 入学时间
*/
@NotNull(message = "最高学历标识不可为空")
@ExcelProperty(value ="最高学历标识")
private String highIdentification;
/**
* 学历类型:全日制、自考、函授等
*/ */
@ExcelProperty(value ="学历类型") @NotNull(message = "入学时间不可为空")
private String type; @DateTimeFormat("YYYY-MM-dd")
@ExcelProperty(value ="入学时间")
private Date entryDate;
/** /**
* 院系名称 * 结业日期
*/ */
@ExcelProperty(value ="院系") @NotNull(message = "毕业时间不可为空")
private String collageSystem; @DateTimeFormat("YYYY-MM-dd")
@ExcelProperty(value ="毕业时间")
private Date gradutionDate;
/** /**
* 证书名称 * 证书名称
......
...@@ -11,7 +11,7 @@ import lombok.Data; ...@@ -11,7 +11,7 @@ import lombok.Data;
* @Version 1.0 * @Version 1.0
*/ */
@Data @Data
public class EmpEducationUpdateVo extends TEmpEducation { public class EmpEducationUpdateVO extends TEmpEducation {
/** /**
* 是否大专及以上(0否1是) * 是否大专及以上(0否1是)
*/ */
......
...@@ -3,14 +3,14 @@ package com.yifu.cloud.plus.v1.yifu.archives.vo; ...@@ -3,14 +3,14 @@ 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.format.DateTimeFormat; import com.alibaba.excel.annotation.format.DateTimeFormat;
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 com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import com.yifu.cloud.plus.v1.yifu.common.security.util.dict.ConverterDiy;
import com.yifu.cloud.plus.v1.yifu.common.security.util.dict.DictValidator;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past; import javax.validation.constraints.Past;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date; import java.util.Date;
/** /**
...@@ -21,36 +21,39 @@ import java.util.Date; ...@@ -21,36 +21,39 @@ import java.util.Date;
*/ */
@Data @Data
@ColumnWidth(30) @ColumnWidth(30)
public class EmpFamilyExcelVO implements Serializable { public class EmpFamilyExcelVO extends RowIndex implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/**
* 员工身份证
*/
@NotNull(message = "员工身份证不可为空")
@ExcelProperty(value ="员工身份证")
private String empIdcard;
/** /**
* 员工姓名 * 员工姓名
*/ */
@NotNull(message = "员工姓名不可为空") @NotNull(message = "员工姓名不可为空")
@ExcelProperty(value ="员工姓名") @ExcelProperty(value ="员工姓名")
private String empName; private String empName;
/** /**
* 与本人关系 * 员工身份证
*/ */
@NotNull(message = "与本人关系不可为空") @NotNull(message = "员工身份证不可为空")
@ExcelProperty(value ="与本人关系") @ExcelProperty(value ="身份证号")
private String relationshipSelf; private String empIdcard;
/** /**
* 家庭成员姓名 * 家庭成员姓名
*/ */
@NotNull(message = "家庭成员姓名不可为空") @NotNull(message = "家庭成员姓名不可为空")
@ExcelProperty(value ="家庭成员姓名") @ExcelProperty(value ="成员姓名")
private String familyName; private String familyName;
/**
* 与本人关系
*/
@ExcelAttribute(name = "与本人关系",isDataId = true,dataType = "family_relation")
//@DictValidator(dictType = "family_relation",message = "与本人关系字典不匹配")
@NotNull(message = "与本人关系不可为空")
@ExcelProperty(value ="与本人关系",converter = ConverterDiy.class )
private String relationshipSelf;
/** /**
* 出生日期 * 出生日期
*/ */
......
...@@ -11,6 +11,7 @@ import javax.validation.constraints.NotNull; ...@@ -11,6 +11,7 @@ import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past; import javax.validation.constraints.Past;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Date;
/** /**
* 员工伤残excel 对应的实体 * 员工伤残excel 对应的实体
...@@ -27,7 +28,7 @@ public class EmpWorkRecordExcelVO implements Serializable { ...@@ -27,7 +28,7 @@ public class EmpWorkRecordExcelVO implements Serializable {
* 员工身份证 * 员工身份证
*/ */
@NotNull(message = "员工身份证不可为空") @NotNull(message = "员工身份证不可为空")
@ExcelProperty(value ="员工身份证") @ExcelProperty(value ="身份证号")
private String empIdcard; private String empIdcard;
/** /**
...@@ -56,33 +57,34 @@ public class EmpWorkRecordExcelVO implements Serializable { ...@@ -56,33 +57,34 @@ public class EmpWorkRecordExcelVO implements Serializable {
@ExcelProperty(value ="工作岗位") @ExcelProperty(value ="工作岗位")
private String workJob; private String workJob;
/**
* 工作类型
*/
@ExcelProperty(value ="工作类型")
private String workingType;
/**
* 是否在岗:0是/1否
*/
@NotNull(message = "是否在岗不可为空")
@ExcelProperty(value ="在职状态")
private String workingStatus;
/** /**
* 开始工作日期 * 开始工作日期
*/ */
@DateTimeFormat("YYYY-MM-dd") @DateTimeFormat("YYYY-MM-dd")
@NotNull(message = "开始工作日期不可为空") @NotNull(message = "开始工作日期不可为空")
@ExcelProperty(value ="开始工作日期") @ExcelProperty(value ="开始工作日期")
private LocalDateTime startDate; private Date startDate;
/** /**
* 结束工作日期 * 结束工作日期
*/ */
@DateTimeFormat("YYYY-MM-dd") @DateTimeFormat("YYYY-MM-dd")
@ExcelProperty(value ="结束工作日期") @ExcelProperty(value ="结束工作日期")
private LocalDateTime endDate; private Date endDate;
/**
* 是否在岗:0是/1否
*/
@NotNull(message = "是否在岗不可为空")
@ExcelProperty(value ="是否在岗")
private String workingStatus;
/**
* 工作类型
*/
@ExcelProperty(value ="工作类型")
private String workingType;
/*JSR303 是一套JavaBean参数校验的标准,它定义了很多常用的校验注解,我们可以直接将这些注解加在我们JavaBean的属性上面,就可以在需要校验的时候进行校验了。注解如下: /*JSR303 是一套JavaBean参数校验的标准,它定义了很多常用的校验注解,我们可以直接将这些注解加在我们JavaBean的属性上面,就可以在需要校验的时候进行校验了。注解如下:
参考配置 参考配置
......
package com.yifu.cloud.plus.v1.yifu.archives.vo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpFamily;
import lombok.Data;
/**
* @Author fxj
* @Date 2022/6/22
* @Description
* @Version 1.0
*/
@Data
public class FamilySearchVO extends TEmpFamily {
private String ids;
}
package com.yifu.cloud.plus.v1.yifu.archives.vo;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @Author fxj
* @Date 2022/6/23
* @Description
* @Version 1.0
*/
@Data
@NoArgsConstructor
public class RowIndex {
private Integer rowIndex;
}
package com.yifu.cloud.plus.v1.yifu.archives.vo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpWorkRecording;
import lombok.Data;
/**
* @Author fxj
* @Date 2022/6/23
* @Description
* @Version 1.0
*/
@Data
public class WorkRecordSearchVO extends TEmpWorkRecording {
private String ids;
}
package com.yifu.cloud.plus.v1.yifu.common.security.util.dict;
import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.converters.ReadConverterContext;
import com.alibaba.excel.converters.WriteConverterContext;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.data.WriteCellData;
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.RedisUtil;
import java.lang.reflect.Field;
import java.util.Map;
/**
* @Author fxj
* @Date 2022/6/23
* @Description
* @Version 1.0
*/
public class ConverterDiy implements Converter<String> {
@Override
public Class<?> supportJavaTypeKey() {
return String.class;
}
@Override
public CellDataTypeEnum supportExcelTypeKey() {
return CellDataTypeEnum.STRING;
}
/**
* 这里是读的时候会调用 不用管
*
* @return
*/
@Override
public String convertToJavaData(ReadConverterContext<?> context) {
Field field = context.getContentProperty().getField();
String converRes = context.getReadCellData().getStringValue();
if (Common.isNotNull(field)){
DictValidator attr = field.getAnnotation(DictValidator.class);
if (Common.isNotNull(attr) && Common.isNotNull(attr.dictType())){
Map<String,String> dicObj = (Map<String, String>) RedisUtil.redis.opsForValue().get(attr.dictType());
for (Map.Entry<String,String> entry:dicObj.entrySet()){
if (Common.isNotNull(entry.getValue()) && entry.getValue().equals(converRes)){
converRes = entry.getKey();
break;
}
}
}
}
return converRes;
}
/**
* 这里是写的时候会调用 不用管
*
* @return
*/
@Override
public WriteCellData<?> convertToExcelData(WriteConverterContext<String> context) {
return new WriteCellData<>("" + context.getValue());
}
}
package com.yifu.cloud.plus.v1.yifu.common.security.util.dict;
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;
/**
* @Author fxj
* @Date 2022/6/22
* @Description 数据字典注解
* @Version 1.0
*/
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER, ElementType.TYPE_USE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Constraint(validatedBy = {DictValuesConstraintValidator.class})
public @interface DictValidator {
/**
* return message
*
* @return
*/
String message() default "字典不匹配";
/**
* a groups element that specifies the processing groups with which the constraint declaration is associated
*/
Class<?>[] groups() default {};
/**
* specifies the payload with which the the constraint declaration is associated
*/
Class<? extends Payload>[] payload() default {};
/**
* 注解传参
*/
String dictType() default "";
/**
* 读取内容转表达式 (如: 0=男,1=女,2=未知)
*/
String readConverterExp() default "父子";
}
package com.yifu.cloud.plus.v1.yifu.common.security.util.dict;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
/**
* @Author fxj
* @Date 2022/6/22
* @Description
* @Version 1.0
*/
public class DictValuesConstraintValidator implements ConstraintValidator<DictValidator,String> {
Set<String> values = new HashSet<>();
@Override
public void initialize(DictValidator constraintAnnotation) {
/*String readConverterExp = constraintAnnotation.readConverterExp();
values.add(readConverterExp);*/
// 获取注解中传入的values信息
String dictType= constraintAnnotation.dictType();
Map<String,String> dicObj = (Map<String, String>) RedisUtil.redis.opsForValue().get(dictType);
// 遍历values信息,放到set中
if (Common.isNotNull(dicObj)){
values.addAll(dicObj.keySet());
}
}
@Override
public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
// 当用户传进来的值符合给定的值才允许通过(return true)
return values.contains(value);
}
}
package com.yifu.cloud.plus.v1.yifu.common.security.util.dict;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.alibaba.excel.exception.ExcelDataConvertException;
import com.alibaba.excel.metadata.CellExtra;
import com.alibaba.excel.metadata.data.ReadCellData;
import com.alibaba.excel.read.metadata.holder.ReadRowHolder;
import com.alibaba.fastjson.JSON;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpFamilyExcelVO;
import lombok.extern.log4j.Log4j2;
import java.util.List;
import java.util.Map;
/**
* @Author fxj
* @Date 2022/6/23
* @Description
* @Version 1.0
*/
@Log4j2
public class ExcelListenerDiy extends AnalysisEventListener<EmpFamilyExcelVO> {
List<EmpFamilyExcelVO> res;
public ExcelListenerDiy(List<EmpFamilyExcelVO> res){
this.res = res;
}
//解析异常调用
@Override
public void onException(Exception exception, AnalysisContext context) throws Exception {
log.error("解析失败,但是继续解析下一行:{}", exception.getMessage());
if (exception instanceof ExcelDataConvertException) {
ExcelDataConvertException excelDataConvertException = (ExcelDataConvertException)exception;
log.error("第{}行,第{}列解析异常,数据为:{}", excelDataConvertException.getRowIndex(),
excelDataConvertException.getColumnIndex(), excelDataConvertException.getCellData());
}
}
//解析表头
@Override
public void invokeHead(Map<Integer, ReadCellData<?>> headMap, AnalysisContext context) {
}
//解析每行数据调用
@Override
public void invoke(EmpFamilyExcelVO data, AnalysisContext context) {
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex+1);
res.add(data);
}
@Override
public void extra(CellExtra extra, AnalysisContext context) {
}
//所有数据解析完成后调用
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
log.info("所有数据解析完成!");
log.info("解析数据:{}", JSON.toJSONString(res));
}
}
...@@ -23,8 +23,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -23,8 +23,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pig4cloud.plugin.excel.annotation.RequestExcel; import com.pig4cloud.plugin.excel.annotation.RequestExcel;
import com.pig4cloud.plugin.excel.vo.ErrorMessage; import com.pig4cloud.plugin.excel.vo.ErrorMessage;
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.entity.TEmpEducation;
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.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.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;
...@@ -67,13 +71,20 @@ public class TEmpDisabilityInfoController { ...@@ -67,13 +71,20 @@ public class TEmpDisabilityInfoController {
/** /**
* 不分页查询 * 不分页查询
* @param tEmpDisabilityInfo 员工伤残信息表 * @param searchVo 员工伤残信息表
* @return * @return
*/ */
@Operation(summary = "不分页查询", description = "不分页查询") @Operation(summary = "不分页查询", description = "不分页查询")
@GetMapping("/noPage" ) @GetMapping("/noPage" )
public R<List<TEmpDisabilityInfo>> getTEmpDisabilityInfoNoPage(TEmpDisabilityInfo tEmpDisabilityInfo) { public R<List<TEmpDisabilityInfo>> getTEmpDisabilityInfoNoPage(DisabilitySearchVo searchVo) {
return R.ok(tEmpDisabilityInfoService.list(Wrappers.query(tEmpDisabilityInfo))); List<String> idList = null;
if (Common.isNotNull(searchVo.getIds())){
idList = Common.initStrToList(searchVo.getIds(), CommonConstants.COMMA_STRING);
}
if (Common.isNotNull(idList)){
return R.ok(tEmpDisabilityInfoService.list( Wrappers.<TEmpDisabilityInfo>query(searchVo).lambda().in(TEmpDisabilityInfo::getId,idList)));
}
return R.ok(tEmpDisabilityInfoService.list(Wrappers.query(searchVo)));
} }
......
...@@ -24,6 +24,7 @@ import com.pig4cloud.plugin.excel.annotation.RequestExcel; ...@@ -24,6 +24,7 @@ import com.pig4cloud.plugin.excel.annotation.RequestExcel;
import com.pig4cloud.plugin.excel.vo.ErrorMessage; import com.pig4cloud.plugin.excel.vo.ErrorMessage;
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.EmpEducationExcelVO; import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationExcelVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationUpdateExcelVo; 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;
...@@ -67,14 +68,20 @@ public class TEmpEducationController { ...@@ -67,14 +68,20 @@ public class TEmpEducationController {
} }
/** /**
* 不分页查询 * 不分页查询
* @param tEmpEducation 员工学历信息表 * @param searchVo 员工学历信息表
* @return * @return
*/ */
@Operation(description = "不分页查询hasPermission('archives_tempeducation_export')") @Operation(description = "不分页查询")
@GetMapping("/noPage" ) @GetMapping("/noPage" )
@PreAuthorize("@pms.hasPermission('archives_tempeducation_export')" ) public R<List<TEmpEducation>> getTEmpEducationNoPage(EducationSearchVo searchVo) {
public R<List<TEmpEducation>> getTEmpEducationNoPage(TEmpEducation tEmpEducation) { List<String> idList = null;
return R.ok(tEmpEducationService.list( Wrappers.query(tEmpEducation))); if (Common.isNotNull(searchVo.getIds())){
idList = Common.initStrToList(searchVo.getIds(),CommonConstants.COMMA_STRING);
}
if (Common.isNotNull(idList)){
return R.ok(tEmpEducationService.list( Wrappers.<TEmpEducation>query(searchVo).lambda().in(TEmpEducation::getId,idList)));
}
return R.ok(tEmpEducationService.list( Wrappers.query(searchVo)));
} }
/** /**
......
...@@ -17,24 +17,31 @@ ...@@ -17,24 +17,31 @@
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.core.toolkit.Wrappers; 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.pig4cloud.plugin.excel.annotation.RequestExcel;
import com.pig4cloud.plugin.excel.vo.ErrorMessage;
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.EmpFamilyExcelVO;
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.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.extern.log4j.Log4j2;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List; import java.util.List;
...@@ -45,6 +52,7 @@ import java.util.List; ...@@ -45,6 +52,7 @@ import java.util.List;
* @author fxj * @author fxj
* @date 2022-06-18 09:39:46 * @date 2022-06-18 09:39:46
*/ */
@Log4j2
@RestController @RestController
@RequiredArgsConstructor @RequiredArgsConstructor
@RequestMapping("/tempfamily" ) @RequestMapping("/tempfamily" )
...@@ -62,17 +70,25 @@ public class TEmpFamilyController { ...@@ -62,17 +70,25 @@ public class TEmpFamilyController {
@Operation(description = "分页查询") @Operation(description = "分页查询")
@GetMapping("/page" ) @GetMapping("/page" )
public R<IPage<TEmpFamily>> getTEmpFamilyPage(Page page, TEmpFamily tEmpFamily) { public R<IPage<TEmpFamily>> getTEmpFamilyPage(Page page, TEmpFamily tEmpFamily) {
//Object codeObj = redisTemplate.opsForValue().get("family_relation");
return R.ok(tEmpFamilyService.page(page, Wrappers.query(tEmpFamily))); return R.ok(tEmpFamilyService.page(page, Wrappers.query(tEmpFamily)));
} }
/** /**
* 不分页查询 * 不分页查询
* @param tEmpFamily 员工家庭信息表 * @param family 员工家庭信息表
* @return * @return
*/ */
@Operation(description = "不分页查询") @Operation(description = "不分页查询")
@GetMapping("/noPage" ) @GetMapping("/noPage" )
public R<List<TEmpFamily>> getTEmpFamilyNoPage(TEmpFamily tEmpFamily) { public R<List<TEmpFamily>> getTEmpFamilyNoPage(FamilySearchVO family) {
return R.ok(tEmpFamilyService.list( Wrappers.query(tEmpFamily))); List<String> idList = null;
if (Common.isNotNull(family.getIds())){
idList = Common.initStrToList(family.getIds(),CommonConstants.COMMA_STRING);
}
if (Common.isNotNull(idList)){
return R.ok(tEmpFamilyService.list( Wrappers.<TEmpFamily>query(family).lambda().in(TEmpFamily::getId,idList)));
}
return R.ok(tEmpFamilyService.list( Wrappers.query(family)));
} }
/** /**
...@@ -83,7 +99,7 @@ public class TEmpFamilyController { ...@@ -83,7 +99,7 @@ public class TEmpFamilyController {
@Operation(description = "通过id查询hasPermission('archives-family-detail')") @Operation(description = "通过id查询hasPermission('archives-family-detail')")
@GetMapping("/{id}" ) @GetMapping("/{id}" )
@PreAuthorize("@pms.hasPermission('archives-family-detail')" ) @PreAuthorize("@pms.hasPermission('archives-family-detail')" )
public R<TEmpFamily> getById(@PathVariable("id" ) Long id) { public R<TEmpFamily> getById(@PathVariable("id" ) String id) {
return R.ok(tEmpFamilyService.getById(id)); return R.ok(tEmpFamilyService.getById(id));
} }
...@@ -154,7 +170,7 @@ public class TEmpFamilyController { ...@@ -154,7 +170,7 @@ public class TEmpFamilyController {
} }
/** /* *//**
* 批量新增员工家庭信息 * 批量新增员工家庭信息
* *
* @param excelVOList * @param excelVOList
...@@ -162,11 +178,79 @@ public class TEmpFamilyController { ...@@ -162,11 +178,79 @@ public class TEmpFamilyController {
* @Author fxj * @Author fxj
* @Date 2019-08-16 * @Date 2019-08-16
**/ **/
@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(@RequestExcel List<EmpFamilyExcelVO> excelVOList, BindingResult bindingResult) { public R<List<ErrorMessage>> importListAdd(@RequestExcel List<EmpFamilyExcelVO> excelVOList, BindingResult bindingResult) {
return tEmpFamilyService.importEmpFamily(excelVOList, bindingResult); return tEmpFamilyService.importEmpFamily(excelVOList, bindingResult);
}*/
/**
* 批量新增员工家庭信息
*
* @param file
* @return
* @Author fxj
* @Date 2019-08-16
**/
@Operation(description = "批量新增员工家庭信息 hasPermission('archives-family-batch-import')")
@SysLog("批量新增员工家庭信息")
@PostMapping("/importListAdd")
@PreAuthorize("@pms.hasPermission('archives-family-batch-import')")
public R<List<ErrorMessage>> importListAdd(@RequestBody MultipartFile file) throws Exception{
/*
List<EmpFamilyExcelVO> excelVOList = new ArrayList<>();
EasyExcel.read(file.getInputStream(),EmpFamilyExcelVO.class,new ExcelListenerDiy(excelVOList)).sheet(0);
return tEmpFamilyService.importEmpFamily(excelVOList, bindingResult);
*/
ExcelUtil<EmpFamilyExcelVO> util1 = null;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
EasyExcel.read(file.getInputStream(), EmpFamilyExcelVO.class, new ReadListener<EmpFamilyExcelVO>() {
/**
* 单次缓存的数据量
*/
public static final int BATCH_COUNT = 1;
/**
*临时存储
*/
private List<EmpFamilyExcelVO> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
@Override
public void invoke(EmpFamilyExcelVO data, AnalysisContext context) {
//List<ObjectError> errorMessages = bindingResult.getAllErrors();
ReadRowHolder readRowHolder = context.readRowHolder();
Integer rowIndex = readRowHolder.getRowIndex();
data.setRowIndex(rowIndex+1);
util1.checkEntity(data, rowIndex);
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());
log.info("存储数据库成功!");
}
}).sheet().doRead();
if (null != util1.getErrorInfo() && !util1.getErrorInfo().isEmpty()) {
return R.failed(util1.getErrorInfo());
}
return null;
} }
} }
...@@ -24,7 +24,10 @@ import com.pig4cloud.plugin.excel.annotation.RequestExcel; ...@@ -24,7 +24,10 @@ import com.pig4cloud.plugin.excel.annotation.RequestExcel;
import com.pig4cloud.plugin.excel.vo.ErrorMessage; import com.pig4cloud.plugin.excel.vo.ErrorMessage;
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.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.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;
...@@ -64,13 +67,22 @@ public class TEmpProfessionalQualificationController { ...@@ -64,13 +67,22 @@ public class TEmpProfessionalQualificationController {
} }
/** /**
* 不分页查询 * 不分页查询
* @param tEmpProfessionalQualification 员工职业资格信息表 * @param searchVo 员工职业资格信息表
* @return * @return
*/ */
@Operation(description = "不分页查询") @Operation(description = "不分页查询")
@GetMapping("/noPage" ) @GetMapping("/noPage" )
public R<List<TEmpProfessionalQualification>> getTEmpProfessionalQualificationNoPage(TEmpProfessionalQualification tEmpProfessionalQualification) { public R<List<TEmpProfessionalQualification>> getTEmpProfessionalQualificationNoPage(CertifySearchVo searchVo) {
return R.ok(qualificationService.list(Wrappers.query(tEmpProfessionalQualification)));
List<String> idList = null;
if (Common.isNotNull(searchVo.getIds())){
idList = Common.initStrToList(searchVo.getIds(), CommonConstants.COMMA_STRING);
}
if (Common.isNotNull(idList)){
return R.ok(qualificationService.list( Wrappers.<TEmpProfessionalQualification>query(searchVo)
.lambda().in(TEmpProfessionalQualification::getId,idList)));
}
return R.ok(qualificationService.list(Wrappers.query(searchVo)));
} }
/** /**
......
...@@ -25,6 +25,7 @@ import com.pig4cloud.plugin.excel.vo.ErrorMessage; ...@@ -25,6 +25,7 @@ import com.pig4cloud.plugin.excel.vo.ErrorMessage;
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.EmpWorkRecordExcelVO;
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.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
...@@ -67,13 +68,21 @@ public class TEmpWorkRecordingController { ...@@ -67,13 +68,21 @@ public class TEmpWorkRecordingController {
/** /**
* 不分页查询 * 不分页查询
* @param tEmpWorkRecording 员工工作履历信息表 * @param searchVo 员工工作履历信息表
* @return * @return
*/ */
@Operation(description = "不分页查询") @Operation(description = "不分页查询")
@GetMapping("/noPage" ) @GetMapping("/noPage" )
public R<List<TEmpWorkRecording>> getTEmpWorkRecordingNoPage(TEmpWorkRecording tEmpWorkRecording) { public R<List<TEmpWorkRecording>> getTEmpWorkRecordingNoPage(WorkRecordSearchVO searchVo) {
return R.ok(tEmpWorkRecordingService.list(Wrappers.query(tEmpWorkRecording))); List<String> idList = null;
if (Common.isNotNull(searchVo.getIds())){
idList = Common.initStrToList(searchVo.getIds(),CommonConstants.COMMA_STRING);
}
if (Common.isNotNull(idList)){
return R.ok(tEmpWorkRecordingService.list( Wrappers.<TEmpWorkRecording>query(searchVo)
.lambda().in(TEmpWorkRecording::getId,idList)));
}
return R.ok(tEmpWorkRecordingService.list(Wrappers.query(searchVo)));
} }
/** /**
* 通过id查询员工工作履历信息表 * 通过id查询员工工作履历信息表
......
...@@ -21,7 +21,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -21,7 +21,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
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.TEmployeeInfo; import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationUpdateVo; import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationUpdateVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -46,7 +46,7 @@ public interface TEmployeeInfoMapper extends BaseMapper<TEmployeeInfo> { ...@@ -46,7 +46,7 @@ public interface TEmployeeInfoMapper extends BaseMapper<TEmployeeInfo> {
// hgw 2022-6-22 15:32:39 根据手机号查询一批档案 // hgw 2022-6-22 15:32:39 根据手机号查询一批档案
List<TEmployeeInfo> getListByPhone(@Param("phoneList") List<String> phoneList); List<TEmployeeInfo> getListByPhone(@Param("phoneList") List<String> phoneList);
int updateEducationOfEmp(@Param("education") EmpEducationUpdateVo education); int updateEducationOfEmp(@Param("education") EmpEducationUpdateVO education);
void updateExcelEmployeeInfo(@Param("list") List<TEmployeeInfo> list); void updateExcelEmployeeInfo(@Param("list") List<TEmployeeInfo> list);
......
...@@ -22,7 +22,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -22,7 +22,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.pig4cloud.plugin.excel.vo.ErrorMessage; import com.pig4cloud.plugin.excel.vo.ErrorMessage;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo; import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationUpdateVo; import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationUpdateVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmployeeVO; import com.yifu.cloud.plus.v1.yifu.archives.vo.EmployeeVO;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
...@@ -130,5 +130,5 @@ public interface TEmployeeInfoService extends IService<TEmployeeInfo> { ...@@ -130,5 +130,5 @@ public interface TEmployeeInfoService extends IService<TEmployeeInfo> {
**/ **/
R<List<ErrorMessage>> batchUpdateEmployee(List<EmployeeVO> excelVOList, BindingResult bindingResult); R<List<ErrorMessage>> batchUpdateEmployee(List<EmployeeVO> excelVOList, BindingResult bindingResult);
void updateEducationOfEmp(EmpEducationUpdateVo education); void updateEducationOfEmp(EmpEducationUpdateVO education);
} }
...@@ -80,6 +80,7 @@ public class TEmpDisabilityInfoServiceImpl extends ServiceImpl<TEmpDisabilityInf ...@@ -80,6 +80,7 @@ public class TEmpDisabilityInfoServiceImpl extends ServiceImpl<TEmpDisabilityInf
errorMessage = errorMsgMap.get(i+2); errorMessage = errorMsgMap.get(i+2);
if (Common.isNotNull(errorMessage)){ if (Common.isNotNull(errorMessage)){
temp.add(errorMessage); temp.add(errorMessage);
errorMsgMap.remove(i+2);
continue; continue;
} }
errorMsg = new HashSet<>(); errorMsg = new HashSet<>();
...@@ -107,6 +108,7 @@ public class TEmpDisabilityInfoServiceImpl extends ServiceImpl<TEmpDisabilityInf ...@@ -107,6 +108,7 @@ public class TEmpDisabilityInfoServiceImpl extends ServiceImpl<TEmpDisabilityInf
temp.add(new ErrorMessage((long) (i + 2), errorMsg)); temp.add(new ErrorMessage((long) (i + 2), errorMsg));
} }
} }
temp.addAll(errorMsgMap.values());
return R.ok(temp); return R.ok(temp);
} }
private void checkRes(List<TEmpDisabilityInfo> list, TEmployeeInfo emp, Set<String> errorMsg, EmpDisabilityExcelVO excel) { private void checkRes(List<TEmpDisabilityInfo> list, TEmployeeInfo emp, Set<String> errorMsg, EmpDisabilityExcelVO excel) {
......
...@@ -29,7 +29,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmployeeInfoMapper; ...@@ -29,7 +29,7 @@ import com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmployeeInfoMapper;
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.EmpEducationExcelVO; import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationExcelVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationUpdateExcelVo; 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.Common;
...@@ -75,10 +75,15 @@ public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, T ...@@ -75,10 +75,15 @@ public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, T
TEmployeeInfo emp; TEmployeeInfo emp;
TEmpEducation exist; TEmpEducation exist;
Set<String> errorMsg; Set<String> errorMsg;
ErrorMessage errorMessage;
List<ErrorMessage> temp = new ArrayList<>();
// 执行数据插入操作 组装 // 执行数据插入操作 组装
for (int i = 0; i < excelVOList.size(); i++) { for (int i = 0; i < excelVOList.size(); i++) {
errorMessage = errorMsgMap.get(i+2);
// 已有验证报错直接下一个 // 已有验证报错直接下一个
if (Common.isNotNull(errorMsgMap.get(i+2))){ if (Common.isNotNull(errorMsgMap.get(i+2))){
temp.add(errorMessage);
errorMsgMap.remove(i+2);
continue; continue;
} }
errorMsg = new HashSet<>(); errorMsg = new HashSet<>();
...@@ -98,16 +103,16 @@ public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, T ...@@ -98,16 +103,16 @@ public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, T
} }
// 数据合法情况 // 数据合法情况
if (CollUtil.isEmpty(errorMsg)) { if (CollUtil.isEmpty(errorMsg)) {
insertExcelPost(excel,emp); insertExcel(excel,emp);
errorMsg.add(CommonConstants.SAVE_SUCCESS);
temp.add(new ErrorMessage((long) (i + 2), errorMsg));
} else { } else {
// 数据不合法 // 数据不合法
errorMessageList.add(new ErrorMessage((long) (i + 2), errorMsg)); temp.add(new ErrorMessage((long) (i + 2), errorMsg));
} }
} }
if (CollUtil.isNotEmpty(errorMessageList)) { temp.addAll(errorMsgMap.values());
return R.failed(errorMessageList); return R.ok(temp);
}
return R.ok();
} }
/** /**
...@@ -173,43 +178,39 @@ public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, T ...@@ -173,43 +178,39 @@ public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, T
errorMessageList.stream().forEach(errorMessage -> errorMsgMap.put(errorMessage.getLineNum(),errorMessage)); errorMessageList.stream().forEach(errorMessage -> errorMsgMap.put(errorMessage.getLineNum(),errorMessage));
} }
// 个性化校验逻辑 // 个性化校验逻辑
List<TEmpEducation> list = this.list();
TEmployeeInfo emp;
TEmpEducation exist;
Set<String> errorMsg; Set<String> errorMsg;
ErrorMessage errorMessage;
List<ErrorMessage> temp = new ArrayList<>();
// 执行数据插入操作 组装 // 执行数据插入操作 组装
for (int i = 0; i < excelVOList.size(); i++) { for (int i = 0; i < excelVOList.size(); i++) {
// 已有验证报错直接下一个 // 已有验证报错直接下一个
if (Common.isNotNull(errorMsgMap.get(i+2))){ errorMessage = errorMsgMap.get(i+2);
if (Common.isNotNull(errorMessage)){
temp.add(errorMessage);
continue; continue;
} }
errorMsg = new HashSet<>(); errorMsg = new HashSet<>();
EmpEducationUpdateExcelVo excel = excelVOList.get(i); EmpEducationUpdateExcelVo excel = excelVOList.get(i);
emp = employeeInfoMapper.selectOne(Wrappers.<TEmployeeInfo>query().lambda()
.eq(TEmployeeInfo::getEmpIdcard,excel.getEmpIdcard())
.eq(TEmployeeInfo::getDeleteFlag, CommonConstants.ZERO_STRING)
.last(CommonConstants.LAST_ONE_SQL));
checkRes(emp, errorMsg, excel, list);
exist = baseMapper.selectOne(Wrappers.<TEmpEducation>query().lambda()
.eq(TEmpEducation::getEmpIdcard,excel.getEmpIdcard())
.eq(TEmpEducation::getEducationName,excel.getEducationName())
.eq(TEmpEducation::getDeleteFlag,CommonConstants.ZERO_STRING).ne(TEmpEducation::getId,excel.getId())
.last(CommonConstants.LAST_ONE_SQL));
if (Common.isNotNull(exist)){
errorMsg.add(MsgUtils.getMessage(ErrorCodes.ARCHIVES_EMP_EDUCATION_EXISTING, excel.getEducationName()));
}
// 数据合法情况 // 数据合法情况
if (CollUtil.isEmpty(errorMsg)) { if (CollUtil.isEmpty(errorMsg)) {
insertExcelPost(excel,emp); updateExcel(excel);
errorMsg.add(CommonConstants.UPDATE_SUCCESS);
temp.add(new ErrorMessage((long) (i + 2), errorMsg));
} else { } else {
// 数据不合法 // 数据不合法
errorMessageList.add(new ErrorMessage((long) (i + 2), errorMsg)); temp.add(new ErrorMessage((long) (i + 2), errorMsg));
} }
} }
if (CollUtil.isNotEmpty(errorMessageList)) { temp.addAll(errorMsgMap.values());
return R.failed(errorMessageList); return R.ok(temp);
} }
return R.ok();
private void updateExcel(EmpEducationUpdateExcelVo excel) {
TEmpEducation update = new TEmpEducation();
BeanUtil.copyProperties(excel, update);
// 更新档案学历信息
updateEducationOfEmp(update);
this.updateById(update);
} }
private void checkRes(TEmployeeInfo emp, Set<String> errorMsg, EmpEducationExcelVO excel, List<TEmpEducation> list) { private void checkRes(TEmployeeInfo emp, Set<String> errorMsg, EmpEducationExcelVO excel, List<TEmpEducation> list) {
...@@ -233,7 +234,7 @@ public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, T ...@@ -233,7 +234,7 @@ public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, T
private void updateEducationOfEmp(TEmpEducation education) { private void updateEducationOfEmp(TEmpEducation education) {
if (CommonConstants.ZERO_STRING.equals(education.getHighIdentification())){ if (CommonConstants.ZERO_STRING.equals(education.getHighIdentification())){
EmpEducationUpdateVo updateVo = new EmpEducationUpdateVo(); EmpEducationUpdateVO updateVo = new EmpEducationUpdateVO();
BeanUtil.copyProperties(education, updateVo); BeanUtil.copyProperties(education, updateVo);
if (Integer.parseInt(education.getEducationName()) >= CommonConstants.FOUR_INT){ if (Integer.parseInt(education.getEducationName()) >= CommonConstants.FOUR_INT){
updateVo.setIsCollege(CommonConstants.ZERO_INT); updateVo.setIsCollege(CommonConstants.ZERO_INT);
...@@ -247,7 +248,7 @@ public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, T ...@@ -247,7 +248,7 @@ public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, T
/** /**
* 插入excel education * 插入excel education
*/ */
private void insertExcelPost(EmpEducationExcelVO excel,TEmployeeInfo emp) { private void insertExcel(EmpEducationExcelVO excel, TEmployeeInfo emp) {
TEmpEducation insert = new TEmpEducation(); TEmpEducation insert = new TEmpEducation();
BeanUtil.copyProperties(excel, insert); BeanUtil.copyProperties(excel, insert);
insert.setDeleteFlag(CommonConstants.ZERO_STRING); insert.setDeleteFlag(CommonConstants.ZERO_STRING);
......
...@@ -79,6 +79,7 @@ public class TEmpFamilyServiceImpl extends ServiceImpl<TEmpFamilyMapper, TEmpFam ...@@ -79,6 +79,7 @@ public class TEmpFamilyServiceImpl extends ServiceImpl<TEmpFamilyMapper, TEmpFam
errorMessage = errorMsgMap.get(i+2); errorMessage = errorMsgMap.get(i+2);
if (Common.isNotNull(errorMessage)){ if (Common.isNotNull(errorMessage)){
temp.add(errorMessage); temp.add(errorMessage);
errorMsgMap.remove(i+2);
continue; continue;
} }
errorMsg = new HashSet<>(); errorMsg = new HashSet<>();
...@@ -106,6 +107,7 @@ public class TEmpFamilyServiceImpl extends ServiceImpl<TEmpFamilyMapper, TEmpFam ...@@ -106,6 +107,7 @@ public class TEmpFamilyServiceImpl extends ServiceImpl<TEmpFamilyMapper, TEmpFam
temp.add(new ErrorMessage((long) (i + 2), errorMsg)); temp.add(new ErrorMessage((long) (i + 2), errorMsg));
} }
} }
temp.addAll(errorMsgMap.values());
return R.ok(temp); return R.ok(temp);
} }
......
...@@ -90,6 +90,7 @@ public class TEmpProfessionalQualificationServiceImpl extends ServiceImpl<TEmpPr ...@@ -90,6 +90,7 @@ public class TEmpProfessionalQualificationServiceImpl extends ServiceImpl<TEmpPr
errorMessage = errorMsgMap.get(i+2); errorMessage = errorMsgMap.get(i+2);
if (Common.isNotNull(errorMessage)){ if (Common.isNotNull(errorMessage)){
temp.add(errorMessage); temp.add(errorMessage);
errorMsgMap.remove(i+2);
continue; continue;
} }
errorMsg = new HashSet<>(); errorMsg = new HashSet<>();
...@@ -117,6 +118,7 @@ public class TEmpProfessionalQualificationServiceImpl extends ServiceImpl<TEmpPr ...@@ -117,6 +118,7 @@ public class TEmpProfessionalQualificationServiceImpl extends ServiceImpl<TEmpPr
temp.add(new ErrorMessage((long) (i + 2), errorMsg)); temp.add(new ErrorMessage((long) (i + 2), errorMsg));
} }
} }
temp.addAll(errorMsgMap.values());
return R.ok(temp); return R.ok(temp);
} }
/** /**
......
...@@ -68,10 +68,15 @@ public class TEmpWorkRecordingServiceImpl extends ServiceImpl<TEmpWorkRecordingM ...@@ -68,10 +68,15 @@ public class TEmpWorkRecordingServiceImpl extends ServiceImpl<TEmpWorkRecordingM
TEmployeeInfo emp; TEmployeeInfo emp;
TEmpWorkRecording exist; TEmpWorkRecording exist;
Set<String> errorMsg; Set<String> errorMsg;
ErrorMessage errorMessage;
List<ErrorMessage> temp = new ArrayList<>();
// 执行数据插入操作 组装 // 执行数据插入操作 组装
for (int i = 0; i < excelVOList.size(); i++) { for (int i = 0; i < excelVOList.size(); i++) {
errorMessage = errorMsgMap.get(i+2);
// 已有验证报错直接下一个 // 已有验证报错直接下一个
if (Common.isNotNull(errorMsgMap.get(i+2))){ if (Common.isNotNull(errorMsgMap.get(i+2))){
temp.add(errorMessage);
errorMsgMap.remove(i+2);
continue; continue;
} }
errorMsg = new HashSet<>(); errorMsg = new HashSet<>();
...@@ -84,7 +89,6 @@ public class TEmpWorkRecordingServiceImpl extends ServiceImpl<TEmpWorkRecordingM ...@@ -84,7 +89,6 @@ public class TEmpWorkRecordingServiceImpl extends ServiceImpl<TEmpWorkRecordingM
exist = baseMapper.selectOne(Wrappers.<TEmpWorkRecording>query().lambda() exist = baseMapper.selectOne(Wrappers.<TEmpWorkRecording>query().lambda()
.eq(TEmpWorkRecording::getEmpIdcard,excel.getEmpIdcard()) .eq(TEmpWorkRecording::getEmpIdcard,excel.getEmpIdcard())
.eq(TEmpWorkRecording::getWorkUnit,excel.getWorkUnit()) .eq(TEmpWorkRecording::getWorkUnit,excel.getWorkUnit())
.eq(TEmpWorkRecording::getWorkJob,excel.getWorkJob())
.eq(TEmpWorkRecording::getWorkDepart,excel.getWorkDepart()) .eq(TEmpWorkRecording::getWorkDepart,excel.getWorkDepart())
.eq(TEmpWorkRecording::getDeleteFlag,CommonConstants.ZERO_STRING) .eq(TEmpWorkRecording::getDeleteFlag,CommonConstants.ZERO_STRING)
.last(CommonConstants.LAST_ONE_SQL)); .last(CommonConstants.LAST_ONE_SQL));
...@@ -94,15 +98,15 @@ public class TEmpWorkRecordingServiceImpl extends ServiceImpl<TEmpWorkRecordingM ...@@ -94,15 +98,15 @@ public class TEmpWorkRecordingServiceImpl extends ServiceImpl<TEmpWorkRecordingM
// 数据合法情况 // 数据合法情况
if (CollUtil.isEmpty(errorMsg)) { if (CollUtil.isEmpty(errorMsg)) {
insertExcelPost(excel,emp); insertExcelPost(excel,emp);
errorMsg.add(CommonConstants.SAVE_SUCCESS);
temp.add(new ErrorMessage((long) (i + 2), errorMsg));
} else { } else {
// 数据不合法 // 数据不合法
errorMessageList.add(new ErrorMessage((long) (i + 2), errorMsg)); temp.add(new ErrorMessage((long) (i + 2), errorMsg));
} }
} }
if (CollUtil.isNotEmpty(errorMessageList)) { temp.addAll(errorMsgMap.values());
return R.failed(errorMessageList); return R.ok(temp);
}
return R.ok();
} }
@Override @Override
...@@ -138,9 +142,6 @@ public class TEmpWorkRecordingServiceImpl extends ServiceImpl<TEmpWorkRecordingM ...@@ -138,9 +142,6 @@ public class TEmpWorkRecordingServiceImpl extends ServiceImpl<TEmpWorkRecordingM
if (StrUtil.isNotBlank(recording.getWorkUnit())){ if (StrUtil.isNotBlank(recording.getWorkUnit())){
wrapper.eq(TEmpWorkRecording::getWorkUnit,recording.getWorkUnit()); wrapper.eq(TEmpWorkRecording::getWorkUnit,recording.getWorkUnit());
} }
if (StrUtil.isNotBlank(recording.getWorkJob())){
wrapper.eq(TEmpWorkRecording::getWorkJob,recording.getWorkJob());
}
if (StrUtil.isNotBlank(recording.getId())){ if (StrUtil.isNotBlank(recording.getId())){
wrapper.ne(TEmpWorkRecording::getId,recording.getId()); wrapper.ne(TEmpWorkRecording::getId,recording.getId());
} }
...@@ -164,7 +165,6 @@ public class TEmpWorkRecordingServiceImpl extends ServiceImpl<TEmpWorkRecordingM ...@@ -164,7 +165,6 @@ public class TEmpWorkRecordingServiceImpl extends ServiceImpl<TEmpWorkRecordingM
// 检查添加是否已经存在 // 检查添加是否已经存在
boolean match = list.stream().anyMatch(info -> excel.getWorkDepart().equals(info.getWorkDepart()) boolean match = list.stream().anyMatch(info -> excel.getWorkDepart().equals(info.getWorkDepart())
&& excel.getWorkUnit().equals(info.getWorkUnit()) && excel.getWorkUnit().equals(info.getWorkUnit())
&& excel.getWorkJob().equals(info.getWorkJob())
&& excel.getEmpIdcard().equals(info.getEmpIdcard())); && excel.getEmpIdcard().equals(info.getEmpIdcard()));
if (match) { if (match) {
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
*/ */
package com.yifu.cloud.plus.v1.yifu.archives.service.impl; package com.yifu.cloud.plus.v1.yifu.archives.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
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;
...@@ -24,14 +23,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; ...@@ -24,14 +23,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.plugin.excel.vo.ErrorMessage; import com.pig4cloud.plugin.excel.vo.ErrorMessage;
import com.yifu.cloud.plus.v1.check.entity.TCheckIdCard; import com.yifu.cloud.plus.v1.check.entity.TCheckIdCard;
import com.yifu.cloud.plus.v1.check.entity.TCheckMobile; import com.yifu.cloud.plus.v1.check.entity.TCheckMobile;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmpFamily;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo; import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeInfo;
import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeProject; import com.yifu.cloud.plus.v1.yifu.archives.entity.TEmployeeProject;
import com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmployeeInfoMapper; import com.yifu.cloud.plus.v1.yifu.archives.mapper.TEmployeeInfoMapper;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmployeeInfoService; import com.yifu.cloud.plus.v1.yifu.archives.service.TEmployeeInfoService;
import com.yifu.cloud.plus.v1.yifu.archives.service.TEmployeeProjectService; import com.yifu.cloud.plus.v1.yifu.archives.service.TEmployeeProjectService;
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.archives.vo.EmpFamilyExcelVO;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmployeeVO; import com.yifu.cloud.plus.v1.yifu.archives.vo.EmployeeVO;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CacheConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants; import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
...@@ -669,7 +666,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T ...@@ -669,7 +666,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
} }
@Override @Override
public void updateEducationOfEmp(EmpEducationUpdateVo education) { public void updateEducationOfEmp(EmpEducationUpdateVO education) {
baseMapper.updateEducationOfEmp(education); baseMapper.updateEducationOfEmp(education);
} }
......
...@@ -231,9 +231,13 @@ public interface CommonConstants { ...@@ -231,9 +231,13 @@ public interface CommonConstants {
String SAVE_SUCCESS = "保存成功!"; String SAVE_SUCCESS = "保存成功!";
String UPDATE_SUCCESS = "更新成功!";
String PARAM_IS_NOT_EMPTY = "参数不可为空"; String PARAM_IS_NOT_EMPTY = "参数不可为空";
// 是否 // 是否
String IS_FALSE = "否"; String IS_FALSE = "否";
String IS_TRUE = "是"; String IS_TRUE = "是";
int SIX_INT = 6;
int EIGHT_INT = 8;
} }
package com.yifu.cloud.plus.v1.yifu.common.core.constant;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @Description Excel配置注解自定义接口
* @author fangxinjiang
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ java.lang.annotation.ElementType.FIELD })
public @interface ExcelAttribute {
/**
* Excel中的列名
*
* @return
*/
public abstract String name();
/**
* 不好用 建议顺序用表头固定
* 列名对应的A,B,C,D...,不指定按照默认顺序排序
*
* @return
*/
public abstract String column() default "";
/**
* 最大长度校验,默认0无需校验
* @return
*/
public abstract int maxLength() default 0;
/**
* 最大值
* @return
*/
public abstract float max() default 0;
/**
* 最小值
* @return
*/
public abstract float min() default 0;
/**
* 提示信息
*
* @return
*/
public abstract String prompt() default "";
/**
* 设置只能选择不能输入的列内容
*
* @return
*/
public abstract String[] combo() default {};
/**
* 是否导出数据
*
* @return
*/
public abstract boolean isExport() default true;
/**
* 是否为重要字段(整列标红,着重显示)
*
* @return
*/
public abstract boolean isMark() default false;
/**
* 是否合计当前列
*
* @return
*/
public abstract boolean isSum() default false;
/**
* 是否必填字段
* @return
*/
public abstract boolean isNotEmpty() default false;
/**
* 是否为电话字段
* @return
*/
public abstract boolean isPhone() default false;
/**
* 是否为身份证
* @return
*/
public abstract boolean isIdCard() default false;
/**
* 是否为日期
* @return
*/
public abstract boolean isDate() default false;
/**
* 是否为邮箱
* @return
*/
public abstract boolean isEmail() default false;
/**
* 是否为Integer
* @return
*/
public abstract boolean isInteger() default false;
/**
* 是否为float
* @return
*/
public abstract boolean isFloat() default false;
/**
* 是否为double
* @return
*/
public abstract boolean isDouble() default false;
/**
* 验证表达式
* @return
*/
public abstract String pattern() default "";
/**
* 数据类型标识或字典表CODE 与 isDataId()同步出现
* 因为字典有的地方有value有的地方用id
* 建议value不用加后缀 id的后缀加_id
* 组装map的时候code=值 冗余一遍code_id =值
* @return
*/
public abstract String dataType() default "";
/**
* 读取内容转表达式 (如: 0=男,1=女,2=未知)
*/
public String readConverterExp() default "";
/**
* 日期格式化字符串
* @return
*/
public abstract String dateFormat() default "YYYY-MM-dd";
/**
* 日期格式化字符串
* @return
*/
public abstract String dateFormatExport() default "";
/**
* 默认错误信息
* @return
*/
public abstract String errorInfo() default "";
/**
* 默认错误信息
* @return
*/
public abstract String errorInfoImport() default "";
/**
* 是否为实体ID 导入要从字典表取数据 导出要对应导出中文数据
* @return
*/
public abstract boolean isDataId() default false;
/**
* 是否为客户单位和结算主体实体ID 导入要从字典表取数据 导出要对应导出中文数据
* @return
*/
public abstract boolean isOrgan() default false;
/**
* 是否为区域数据 前提:isDataId = true
* @Author fxj
* @Date 2019-09-02
* @param
* @return
**/
public abstract boolean isArea() default false;
/**
* 父ID 前提:isDataId = true
* @Author fxj
* @Date 2019-09-02
* @param
* @return
**/
public abstract String parentField() default "";
/**
* 导出字段组合 只用于导出
* @Author fxj
* @Date 2019-10-11
* @param
* @return
**/
public abstract String componentFieldExport() default "";
/**
* 用于返回可选择导出的中文字段
* @param
* @Author: wangan
* @Date: 2019/10/17
* @Description:
* @return: boolean
**/
public abstract boolean needExport() default false;
/**
* @param
* @Author: wangan
* @Date: 2020/11/5
* @Description: 字典映射不成功是否展示字典key
* @return: boolean
**/
public abstract boolean noRelationExport() default true;
/**
* 是否为实体ID 导入要从字典表取数据 导出要对应导出中文数据
* @return
*/
public abstract String divider() default "";
/**
* @description: 错误信息 需要对字段值提前设置 error= 前缀为错误信息展示为红色, success= 前缀为正确信息展示为绿色
* @return: boolean 是否开启错误信息展示,对字体颜色进行修改
* @author: wangweiguo
* @date: 2021/6/30
*/
public abstract boolean errorMsg() default false;
}
package com.yifu.cloud.plus.v1.yifu.common.core.constant;
/**
* @author fang
* 常用的一些验证,如手机、移动号码、联通号码、电信号码、密码、座机、 邮政编码、邮箱、年龄、身份证、URL、QQ、汉字、字母、数字等校验表达式
*/
public class ValidityConstants {
/** 工资-档案-手机号规则 */
public static final String EMP_PHONE_PATTERN = "^1[3-9]\\d{9}$";
/** 手机号规则 hgw2022-1-14 19:24:48客服刘岚有一个电信客户的手机号是16655125569故变更规则 */
public static final String MOBILE_PATTERN="^(1[3-9][0-9])(\\d{8})$";
/** 中国电信号码格式验证 手机段: 133,153,180,181,189,177,1700,173 **/
public static final String CHINA_TELECOM_PATTERN = "(?:^(?:\\+86)?1(?:33|53|7[37]|8[019])\\d{8}$)|(?:^(?:\\+86)?1700\\d{7}$)";
/** 中国联通号码格式验证 手机段:130,131,132,155,156,185,186,145,176,1707,1708,1709,175 **/
public static final String CHINA_UNICOM_PATTERN = "(?:^(?:\\+86)?1(?:3[0-2]|4[5]|5[56]|7[56]|8[56])\\d{8}$)|(?:^(?:\\+86)?170[7-9]\\d{7}$)";
/** 中国移动号码格式验证 手机段:134,135,136,137,138,139,150,151,152,157,158,159,182,183,184,187,188,147,178,1705 **/
public static final String CHINA_MOVE_PATTERN = "(?:^(?:\\+86)?1(?:3[4-9]|4[7]|5[0-27-9]|7[8]|8[2-478])\\d{8}$)|(?:^(?:\\+86)?1705\\d{7}$)";
/** 密码规则(6-16位字母、数字) */
public static final String PASSWORD_PATTERN="^[0-9A-Za-z]{6,16}$";
/** 固号(座机)规则 */
public static final String LANDLINE_PATTERN="^(?:\\(\\d{3,4}\\)|\\d{3,4}-)?\\d{7,8}(?:-\\d{1,4})?$";
/** 邮政编码规则 */
public static final String POSTCODE_PATTERN = "[1-9]\\d{5}" ;
/** 邮箱规则 */
public static final String EMAIL_PATTERN = "^([a-z0-9A-Z]+[-|_|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$" ;
/** 年龄规则 1-120之间 */
public static final String AGE_PATTERN="^(?:[1-9][0-9]?|1[01][0-9]|120)$";
/** 身份证规则 */
public static final String IDCARD_PATTERN="(^[1-9]\\d{5}(18|19|20)\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$)|(^[1-9]\\d{5}\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}$)" ;
/** URL规则,http、www、ftp */
public static final String URL_PATTERN = "http(s)?://([\\w-]+\\.)+[\\w-]+(/[\\w- ./?%&=]*)?" ;
/** QQ规则 */
public static final String QQ_PATTERN = "^[1-9][0-9]{4,13}$" ;
/** 全汉字规则 */
public static final String CHINESE_PATTERN = "^[\u4E00-\u9FA5]+$" ;
/** 全字母规则 */
public static final String STR_ENG_PATTERN="^[A-Za-z]+$";
/** 整数规则 */
public static final String INTEGER_PATTERN = "^-?[0-9]+$" ;
/** 正整数规则 */
public static final String POSITIVE_INTEGER_PATTERN = "^\\+?[1-9][0-9]*$" ;
/**浮点数规则*/
public static final String FLOAT_PATTERN = "^(-?\\d+)(\\.\\d+)?$";
/**日期格式化1*/
public static final String DATEFORMAT1_PATTERN = "YYYY-MM-dd";
/**日期格式化2*/
public static final String DATEFORMAT2_PATTERN = "yyyy-MM-dd HH:mm:ss";
/**日期格式化3*/
public static final String DATEFORMAT3_PATTERN = "YYYY-MM";
}
package com.yifu.cloud.plus.v1.yifu.common.core.util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.io.Serializable;
import java.util.Set;
import java.util.concurrent.TimeUnit;
/**
* @Author fxj
* @Date 2022/6/22
* @Description
* @Version 1.0
*/
@Component
public class RedisUtil {
@Autowired
private RedisTemplate redisTemplate;
public static RedisTemplate redis;
@PostConstruct
public void getRedisTemplate(){
redis = redisTemplate;
}
/**
* 批量删除对应的Value
* @param keys
*/
public void remove(final String... keys) {
for (String key : keys) {
remove(key);
}
}
/**
* 批量删除KEY
* @param pattern
*/
public void removePattern(final String pattern) {
Set<Serializable> keys = redisTemplate.keys(pattern);
if (keys.size() > 0) {
redisTemplate.delete(keys);
}
}
/**
* 删除对应的value
* @param key
*/
public void remove(final String key){
if (exists(key)){
redisTemplate.delete(key);
}
}
/**
* 判断缓存中是否有对应的value
* @param key
* @return
*/
public boolean exists(final String key){
return redisTemplate.hasKey(key);
}
/**
* 读取缓存
* @param key
* @return
*/
public Object get(final String key){
Object result = null;
ValueOperations<Serializable,Object> operations = redisTemplate.opsForValue();
result = operations.get(key);
return result;
}
/**
* 写入缓存
* @param key
* @param value
* @return
*/
public boolean set(final String key ,Object value){
boolean result = false;
try {
ValueOperations<Serializable,Object> operations = redisTemplate.opsForValue();
operations.set(key,value);
result = true;
} catch (Exception e){
e.printStackTrace();
}
return result;
}
/**
* 写入缓存
* @param key
* @param value
* @param expireTime
* @return
*/
public boolean set(final String key ,Object value,Long expireTime){
boolean result = false;
try {
ValueOperations<Serializable,Object> operations = redisTemplate.opsForValue();
operations.set(key,value);
redisTemplate.expire(key,expireTime, TimeUnit.SECONDS);
result = true;
} catch (Exception e){
e.printStackTrace();
}
return result;
}
}
package com.yifu.cloud.plus.v1.yifu.common.core.util;
import lombok.Data;
import java.io.Serializable;
/**
* @author fang
*/
@Data
public class ErrorMessage implements Serializable {
/**
* 行数或INDEX
*/
private Integer line;
//默认红色 success green
private String color = "red";
/**
* @param 用于展示勾选的名称
* @Author: wangan
**/
private String name;
/**
* 错误信息
*/
private String message;
public ErrorMessage(Integer line, String message) {
this.line = line;
this.message = message;
}
public ErrorMessage(Integer line, String message, String color) {
this.line = line;
this.color = color;
this.message = message;
}
public ErrorMessage(Integer line, String message, String color, String name) {
this.line = line;
this.color = color;
this.message = message;
this.name= name;
}
}
...@@ -4,4 +4,5 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ ...@@ -4,4 +4,5 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.yifu.cloud.plus.v1.yifu.common.core.config.RestTemplateConfiguration,\ com.yifu.cloud.plus.v1.yifu.common.core.config.RestTemplateConfiguration,\
com.yifu.cloud.plus.v1.yifu.common.core.util.SpringContextHolder,\ com.yifu.cloud.plus.v1.yifu.common.core.util.SpringContextHolder,\
com.yifu.cloud.plus.v1.yifu.common.core.config.WebMvcConfiguration,\ com.yifu.cloud.plus.v1.yifu.common.core.config.WebMvcConfiguration,\
com.yifu.cloud.plus.v1.yifu.common.core.util.OSSUtil com.yifu.cloud.plus.v1.yifu.common.core.util.OSSUtil,\
com.yifu.cloud.plus.v1.yifu.common.core.util.RedisUtil
...@@ -7,10 +7,12 @@ import com.yifu.cloud.plus.v1.job.entity.SysScheduleJob; ...@@ -7,10 +7,12 @@ import com.yifu.cloud.plus.v1.job.entity.SysScheduleJob;
import com.yifu.cloud.plus.v1.job.service.SysScheduleJobService; import com.yifu.cloud.plus.v1.job.service.SysScheduleJobService;
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.R; import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import com.yifu.cloud.plus.v1.yifu.common.core.util.RedisUtil;
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 org.springframework.data.redis.core.RedisTemplate;
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.*;
......
com.yifu.cloud.plus.v1.yifu.common.feign.YifuFeignAutoConfiguration=\ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.yifu.cloud.plus.v1.yifu.admin.api.feign.RemoteDictService,\ com.yifu.cloud.plus.v1.yifu.common.core.config.JacksonConfiguration
com.yifu.cloud.plus.v1.yifu.admin.api.feign.RemoteDeptService,\ \ No newline at end of file
com.yifu.cloud.plus.v1.yifu.admin.api.feign.RemoteLogService,\
com.yifu.cloud.plus.v1.yifu.admin.api.feign.RemoteTokenService,\
com.yifu.cloud.plus.v1.yifu.admin.api.feign.RemoteUserService,\
com.yifu.cloud.plus.v1.yifu.admin.api.feign.RemoteParamService
...@@ -79,5 +79,7 @@ public interface SysDictItemService extends IService<SysDictItem> { ...@@ -79,5 +79,7 @@ public interface SysDictItemService extends IService<SysDictItem> {
**/ **/
R<Map<String, Map<String, String>>> getDictToValue(); R<Map<String, Map<String, String>>> getDictToValue();
Map<String, Object> getAllDictItemSub();
void clearDictItemCache(); void clearDictItemCache();
} }
...@@ -168,11 +168,15 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi ...@@ -168,11 +168,15 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi
@CacheEvict(value = CacheConstants.DICT_ITEM_DETAILS, key = CacheConstants.DICT_ITEM_DETAILS) @CacheEvict(value = CacheConstants.DICT_ITEM_DETAILS, key = CacheConstants.DICT_ITEM_DETAILS)
@Override @Override
public R<Map<String, Object>> getAllDictItem() { public R<Map<String, Object>> getAllDictItem() {
return R.ok(getAllDictItemSub());
}
@Override
public Map<String, Object> getAllDictItemSub(){
List<SysDictItem> allList = baseMapper.selectList(Wrappers.<SysDictItem>query().lambda() List<SysDictItem> allList = baseMapper.selectList(Wrappers.<SysDictItem>query().lambda()
.eq(SysDictItem::getDelFlag,CommonConstants.ZERO_STRING)); .eq(SysDictItem::getDelFlag,CommonConstants.ZERO_STRING));
Map<String, Object> resultMap = new HashMap<>(); Map<String, Object> resultMap = new HashMap<>();
extracted(allList, resultMap); extracted(allList, resultMap);
return R.ok(resultMap); return resultMap;
} }
/** /**
* @Author fxj * @Author fxj
......
package com.yifu.cloud.plus.v1.yifu.admin.init;
import com.yifu.cloud.plus.v1.yifu.admin.service.SysDictItemService;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.RedisUtil;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.util.Map;
/**
* @Author fxj
* @Date 2022/6/23
* @Description
* @Version 1.0
*/
@Log4j2
@Component
public class DictItemRedisInit {
@Autowired
private SysDictItemService dictItemService;
@Autowired
private RedisUtil redisUtil;
@PostConstruct
public void init(){
log.info("字典数据加入缓存初始化开始...");
Map<String, Object> dictItem = dictItemService.getAllDictItemSub();
if (Common.isNotNull(dictItem)){
for (Map.Entry<String,Object> entry:dictItem.entrySet()){
redisUtil.set(entry.getKey(),entry.getValue());
}
}
log.info("字典数据加入缓存初始化结束...");
}
}
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.yifu.cloud.plus.v1.yifu.admin.init.DictItemRedisInit
\ No newline at end of file
...@@ -49,6 +49,7 @@ public class ${className} extends BaseEntity { ...@@ -49,6 +49,7 @@ public class ${className} extends BaseEntity {
#if($column.columnName == $pk.columnName) #if($column.columnName == $pk.columnName)
@TableId(type = IdType.ASSIGN_ID) @TableId(type = IdType.ASSIGN_ID)
#end #end
@ExcelAttribute(name = "$column.comments"#if($column.isNullable =='NO' && $column.attrType !='LocalDate' && $column.attrType !='LocalDateTime'), isNotEmpty = true,errorInfo = "$column.comments不能为空"#end #if($column.maxLength), maxLength = $column.maxLength #end)
@Schema(description ="$column.comments"#if($column.hidden),hidden=$column.hidden#end) @Schema(description ="$column.comments"#if($column.hidden),hidden=$column.hidden#end)
private $column.attrType $column.lowerAttrName; private $column.attrType $column.lowerAttrName;
......
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