Commit 71d52d2c authored by fangxinjiang's avatar fangxinjiang

excel导入导出组件

parent 0aaf43f5
......@@ -36,5 +36,9 @@
<groupId>com.pig4cloud.excel</groupId>
<artifactId>excel-spring-boot-starter</artifactId>
</dependency>
</dependencies>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
</dependencies>
</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 {
* 员工身份证
*/
@NotNull(message = "员工身份证不可为空")
@ExcelProperty(value ="员工身份证")
@ExcelProperty(value ="身份证号")
private String empIdcard;
/**
......
......@@ -13,6 +13,7 @@ import javax.validation.constraints.Past;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
/**
* 员工伤残excel 对应的实体
......@@ -30,7 +31,7 @@ public class EmpDisabilityExcelVO implements Serializable {
* 员工身份证
*/
@NotNull(message = "员工身份证不能为空")
@ExcelProperty(value ="员工身份证")
@ExcelProperty(value ="身份证号")
private String empIdcard;
/**
* 员工姓名
......@@ -45,6 +46,12 @@ public class EmpDisabilityExcelVO implements Serializable {
@ExcelProperty(value ="伤残病名称")
private String disabilityName;
/**
* 职业病名称
*/
@ExcelProperty(value ="职业病名称")
private String occupationalDisease;
/**
* 伤残等级
*/
......@@ -52,13 +59,6 @@ public class EmpDisabilityExcelVO implements Serializable {
@ExcelProperty(value ="伤残等级")
private String disabilityLevel;
/**
* 是否工伤标识0是/1否
*/
@NotNull(message = "是否工伤标识(0是/1否)不能为空")
@ExcelProperty(value ="是否工伤")
private String injuryIdentification;
/**
* 伤残开始日期
*/
......@@ -66,7 +66,7 @@ public class EmpDisabilityExcelVO implements Serializable {
@Past
@DateTimeFormat("YYYY-MM-dd")
@ExcelProperty(value ="伤残开始日期")
private LocalDateTime startTime;
private Date startTime;
/**
* 伤残结束日期
......@@ -75,13 +75,14 @@ public class EmpDisabilityExcelVO implements Serializable {
@Past
@DateTimeFormat("YYYY-MM-dd")
@ExcelProperty(value ="伤残结束日期")
private LocalDateTime endTime;
private Date endTime;
/**
* 职业病名称
* 是否工伤标识0是/1否
*/
@ExcelProperty(value ="职业病名称")
private String occupationalDisease;
@NotNull(message = "是否工伤标识(0是/1否)不能为空")
@ExcelProperty(value ="是否工伤")
private String injuryIdentification;
/**
* 备注
......
......@@ -8,6 +8,7 @@ import lombok.Data;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
/**
* 员工伤残excel 对应的实体
......@@ -32,25 +33,28 @@ public class EmpEducationExcelVO implements Serializable {
* 身份证号
*/
@NotNull(message = "员工身份证不可为空")
@ExcelProperty(value ="员工身份证")
@ExcelProperty(value ="身份证号")
private String empIdcard;
/**
* 学校名称
*/
@NotNull(message = "学校不可为空")
@ExcelProperty(value ="学校")
private String school;
/**
* 入学时间
* 院系名称
*/
@NotNull(message = "入学时间不可为空")
@DateTimeFormat("YYYY-MM-dd")
@ExcelProperty(value ="入学时间")
private LocalDateTime entryDate;
@ExcelProperty(value ="院系名称")
private String collageSystem;
/**
* 结业日期
* 专业
*/
@NotNull(message = "毕业时间不可为空")
@DateTimeFormat("YYYY-MM-dd")
@ExcelProperty(value ="毕业时间")
private LocalDateTime gradutionDate;
@NotNull(message = "专业不可为空")
@ExcelProperty(value ="专业")
private String major;
/**
* 学历名称
......@@ -60,42 +64,39 @@ public class EmpEducationExcelVO implements Serializable {
private String educationName;
/**
* 学校名称
* 学历类型:全日制、自考、函授等
*/
@NotNull(message = "学校不可为空")
@ExcelProperty(value ="学校")
private String school;
@ExcelProperty(value ="学历类型")
private String type;
/**
* 专业
* 最高学历标识0是/1否
*/
@ExcelProperty(value ="专业")
private String major;
@NotNull(message = "最高学历标识不可为空")
@ExcelProperty(value ="最高学历")
private String highIdentification;
/**
* 学制类型:四年、三年、五年、二年
*/
@ExcelProperty(value ="学制")
@ExcelProperty(value ="学制类型")
private String educationSystem;
/**
* 最高学历标识0是/1否
*/
@NotNull(message = "最高学历标识不可为空")
@ExcelProperty(value ="最高学历标识")
private String highIdentification;
/**
* 学历类型:全日制、自考、函授等
* 入学时间
*/
@ExcelProperty(value ="学历类型")
private String type;
@NotNull(message = "入学时间不可为空")
@DateTimeFormat("YYYY-MM-dd")
@ExcelProperty(value ="入学时间")
private Date entryDate;
/**
* 院系名称
* 结业日期
*/
@ExcelProperty(value ="院系")
private String collageSystem;
@NotNull(message = "毕业时间不可为空")
@DateTimeFormat("YYYY-MM-dd")
@ExcelProperty(value ="毕业时间")
private Date gradutionDate;
/**
* 证书名称
......
......@@ -5,7 +5,7 @@ import com.alibaba.excel.annotation.format.DateTimeFormat;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.Date;
/**
* @Author fxj
......@@ -14,7 +14,7 @@ import java.time.LocalDateTime;
* @Version 1.0
*/
@Data
public class EmpEducationUpdateExcelVo extends EmpEducationExcelVO{
public class EmpEducationUpdateExcelVo{
/**
* @Author fxj
* @Description 主键
......@@ -24,20 +24,25 @@ public class EmpEducationUpdateExcelVo extends EmpEducationExcelVO{
private String id;
/**
* 入学时间
* 学校名称
*/
@NotNull(message = "入学时间不可为空")
@DateTimeFormat("YYYY-MM-dd")
@ExcelProperty(value ="入学时间")
private LocalDateTime entryDate;
@NotNull(message = "学校不可为空")
@ExcelProperty(value ="学校")
private String school;
/**
* 结业日期
* 院系名称
*/
@NotNull(message = "毕业时间不可为空")
@DateTimeFormat("YYYY-MM-dd")
@ExcelProperty(value ="毕业时间")
private LocalDateTime gradutionDate;
@ExcelProperty(value ="院系名称")
private String collageSystem;
/**
* 专业
*/
@NotNull(message = "专业不可为空")
@ExcelProperty(value ="专业")
private String major;
/**
* 学历名称
......@@ -47,42 +52,39 @@ public class EmpEducationUpdateExcelVo extends EmpEducationExcelVO{
private String educationName;
/**
* 学校名称
* 学历类型:全日制、自考、函授等
*/
@NotNull(message = "学校不可为空")
@ExcelProperty(value ="学校")
private String school;
@ExcelProperty(value ="学历类型")
private String type;
/**
* 专业
* 最高学历标识0是/1否
*/
@ExcelProperty(value ="专业")
private String major;
@NotNull(message = "最高学历标识不可为空")
@ExcelProperty(value ="最高学历")
private String highIdentification;
/**
* 学制类型:四年、三年、五年、二年
*/
@ExcelProperty(value ="学制")
@ExcelProperty(value ="学制类型")
private String educationSystem;
/**
* 最高学历标识0是/1否
*/
@NotNull(message = "最高学历标识不可为空")
@ExcelProperty(value ="最高学历标识")
private String highIdentification;
/**
* 学历类型:全日制、自考、函授等
* 入学时间
*/
@ExcelProperty(value ="学历类型")
private String type;
@NotNull(message = "入学时间不可为空")
@DateTimeFormat("YYYY-MM-dd")
@ExcelProperty(value ="入学时间")
private Date entryDate;
/**
* 院系名称
* 结业日期
*/
@ExcelProperty(value ="院系")
private String collageSystem;
@NotNull(message = "毕业时间不可为空")
@DateTimeFormat("YYYY-MM-dd")
@ExcelProperty(value ="毕业时间")
private Date gradutionDate;
/**
* 证书名称
......
......@@ -11,7 +11,7 @@ import lombok.Data;
* @Version 1.0
*/
@Data
public class EmpEducationUpdateVo extends TEmpEducation {
public class EmpEducationUpdateVO extends TEmpEducation {
/**
* 是否大专及以上(0否1是)
*/
......
......@@ -3,14 +3,14 @@ package com.yifu.cloud.plus.v1.yifu.archives.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
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 javax.validation.constraints.Max;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
/**
......@@ -21,36 +21,39 @@ import java.util.Date;
*/
@Data
@ColumnWidth(30)
public class EmpFamilyExcelVO implements Serializable {
public class EmpFamilyExcelVO extends RowIndex implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 员工身份证
*/
@NotNull(message = "员工身份证不可为空")
@ExcelProperty(value ="员工身份证")
private String empIdcard;
/**
* 员工姓名
*/
@NotNull(message = "员工姓名不可为空")
@ExcelProperty(value ="员工姓名")
private String empName;
/**
* 与本人关系
* 员工身份证
*/
@NotNull(message = "与本人关系不可为空")
@ExcelProperty(value ="与本人关系")
private String relationshipSelf;
@NotNull(message = "员工身份证不可为空")
@ExcelProperty(value ="身份证号")
private String empIdcard;
/**
* 家庭成员姓名
*/
@NotNull(message = "家庭成员姓名不可为空")
@ExcelProperty(value ="家庭成员姓名")
@ExcelProperty(value ="成员姓名")
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;
import javax.validation.constraints.Past;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Date;
/**
* 员工伤残excel 对应的实体
......@@ -27,7 +28,7 @@ public class EmpWorkRecordExcelVO implements Serializable {
* 员工身份证
*/
@NotNull(message = "员工身份证不可为空")
@ExcelProperty(value ="员工身份证")
@ExcelProperty(value ="身份证号")
private String empIdcard;
/**
......@@ -56,33 +57,34 @@ public class EmpWorkRecordExcelVO implements Serializable {
@ExcelProperty(value ="工作岗位")
private String workJob;
/**
* 工作类型
*/
@ExcelProperty(value ="工作类型")
private String workingType;
/**
* 是否在岗:0是/1否
*/
@NotNull(message = "是否在岗不可为空")
@ExcelProperty(value ="在职状态")
private String workingStatus;
/**
* 开始工作日期
*/
@DateTimeFormat("YYYY-MM-dd")
@NotNull(message = "开始工作日期不可为空")
@ExcelProperty(value ="开始工作日期")
private LocalDateTime startDate;
private Date startDate;
/**
* 结束工作日期
*/
@DateTimeFormat("YYYY-MM-dd")
@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的属性上面,就可以在需要校验的时候进行校验了。注解如下:
参考配置
......
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;
import com.pig4cloud.plugin.excel.annotation.RequestExcel;
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.TEmpEducation;
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.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.log.annotation.SysLog;
import io.swagger.v3.oas.annotations.Operation;
......@@ -67,13 +71,20 @@ public class TEmpDisabilityInfoController {
/**
* 不分页查询
* @param tEmpDisabilityInfo 员工伤残信息表
* @param searchVo 员工伤残信息表
* @return
*/
@Operation(summary = "不分页查询", description = "不分页查询")
@GetMapping("/noPage" )
public R<List<TEmpDisabilityInfo>> getTEmpDisabilityInfoNoPage(TEmpDisabilityInfo tEmpDisabilityInfo) {
return R.ok(tEmpDisabilityInfoService.list(Wrappers.query(tEmpDisabilityInfo)));
public R<List<TEmpDisabilityInfo>> getTEmpDisabilityInfoNoPage(DisabilitySearchVo searchVo) {
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;
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.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.EmpEducationUpdateExcelVo;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
......@@ -67,14 +68,20 @@ public class TEmpEducationController {
}
/**
* 不分页查询
* @param tEmpEducation 员工学历信息表
* @param searchVo 员工学历信息表
* @return
*/
@Operation(description = "不分页查询hasPermission('archives_tempeducation_export')")
@Operation(description = "不分页查询")
@GetMapping("/noPage" )
@PreAuthorize("@pms.hasPermission('archives_tempeducation_export')" )
public R<List<TEmpEducation>> getTEmpEducationNoPage(TEmpEducation tEmpEducation) {
return R.ok(tEmpEducationService.list( Wrappers.query(tEmpEducation)));
public R<List<TEmpEducation>> getTEmpEducationNoPage(EducationSearchVo searchVo) {
List<String> idList = null;
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 @@
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.toolkit.Wrappers;
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.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.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.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.log.annotation.SysLog;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
......@@ -45,6 +52,7 @@ import java.util.List;
* @author fxj
* @date 2022-06-18 09:39:46
*/
@Log4j2
@RestController
@RequiredArgsConstructor
@RequestMapping("/tempfamily" )
......@@ -62,17 +70,25 @@ public class TEmpFamilyController {
@Operation(description = "分页查询")
@GetMapping("/page" )
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)));
}
/**
* 不分页查询
* @param tEmpFamily 员工家庭信息表
* @param family 员工家庭信息表
* @return
*/
@Operation(description = "不分页查询")
@GetMapping("/noPage" )
public R<List<TEmpFamily>> getTEmpFamilyNoPage(TEmpFamily tEmpFamily) {
return R.ok(tEmpFamilyService.list( Wrappers.query(tEmpFamily)));
public R<List<TEmpFamily>> getTEmpFamilyNoPage(FamilySearchVO family) {
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 {
@Operation(description = "通过id查询hasPermission('archives-family-detail')")
@GetMapping("/{id}" )
@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));
}
......@@ -154,7 +170,7 @@ public class TEmpFamilyController {
}
/**
/* *//**
* 批量新增员工家庭信息
*
* @param excelVOList
......@@ -162,11 +178,79 @@ public class TEmpFamilyController {
* @Author fxj
* @Date 2019-08-16
**/
@Operation(description = "批量新增员工家庭信息 hasPermission('archives-family-batch-import')")
/* @Operation(description = "批量新增员工家庭信息 hasPermission('archives-family-batch-import')")
@SysLog("批量新增员工家庭信息")
@PostMapping("/importListAdd")
@PreAuthorize("@pms.hasPermission('archives-family-batch-import')")
public R<List<ErrorMessage>> importListAdd(@RequestExcel List<EmpFamilyExcelVO> excelVOList, BindingResult 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;
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.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.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.log.annotation.SysLog;
import io.swagger.v3.oas.annotations.Operation;
......@@ -64,13 +67,22 @@ public class TEmpProfessionalQualificationController {
}
/**
* 不分页查询
* @param tEmpProfessionalQualification 员工职业资格信息表
* @param searchVo 员工职业资格信息表
* @return
*/
@Operation(description = "不分页查询")
@GetMapping("/noPage" )
public R<List<TEmpProfessionalQualification>> getTEmpProfessionalQualificationNoPage(TEmpProfessionalQualification tEmpProfessionalQualification) {
return R.ok(qualificationService.list(Wrappers.query(tEmpProfessionalQualification)));
public R<List<TEmpProfessionalQualification>> getTEmpProfessionalQualificationNoPage(CertifySearchVo searchVo) {
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;
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.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.util.Common;
import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
......@@ -67,13 +68,21 @@ public class TEmpWorkRecordingController {
/**
* 不分页查询
* @param tEmpWorkRecording 员工工作履历信息表
* @param searchVo 员工工作履历信息表
* @return
*/
@Operation(description = "不分页查询")
@GetMapping("/noPage" )
public R<List<TEmpWorkRecording>> getTEmpWorkRecordingNoPage(TEmpWorkRecording tEmpWorkRecording) {
return R.ok(tEmpWorkRecordingService.list(Wrappers.query(tEmpWorkRecording)));
public R<List<TEmpWorkRecording>> getTEmpWorkRecordingNoPage(WorkRecordSearchVO searchVo) {
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查询员工工作履历信息表
......
......@@ -21,7 +21,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
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.vo.EmpEducationUpdateVo;
import com.yifu.cloud.plus.v1.yifu.archives.vo.EmpEducationUpdateVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -46,7 +46,7 @@ public interface TEmployeeInfoMapper extends BaseMapper<TEmployeeInfo> {
// hgw 2022-6-22 15:32:39 根据手机号查询一批档案
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);
......
......@@ -22,7 +22,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
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.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.common.core.util.R;
import org.springframework.validation.BindingResult;
......@@ -130,5 +130,5 @@ public interface TEmployeeInfoService extends IService<TEmployeeInfo> {
**/
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
errorMessage = errorMsgMap.get(i+2);
if (Common.isNotNull(errorMessage)){
temp.add(errorMessage);
errorMsgMap.remove(i+2);
continue;
}
errorMsg = new HashSet<>();
......@@ -107,6 +108,7 @@ public class TEmpDisabilityInfoServiceImpl extends ServiceImpl<TEmpDisabilityInf
temp.add(new ErrorMessage((long) (i + 2), errorMsg));
}
}
temp.addAll(errorMsgMap.values());
return R.ok(temp);
}
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;
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.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.exception.ErrorCodes;
import com.yifu.cloud.plus.v1.yifu.common.core.util.Common;
......@@ -75,10 +75,15 @@ public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, T
TEmployeeInfo emp;
TEmpEducation exist;
Set<String> errorMsg;
ErrorMessage errorMessage;
List<ErrorMessage> temp = new ArrayList<>();
// 执行数据插入操作 组装
for (int i = 0; i < excelVOList.size(); i++) {
errorMessage = errorMsgMap.get(i+2);
// 已有验证报错直接下一个
if (Common.isNotNull(errorMsgMap.get(i+2))){
temp.add(errorMessage);
errorMsgMap.remove(i+2);
continue;
}
errorMsg = new HashSet<>();
......@@ -98,16 +103,16 @@ public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, T
}
// 数据合法情况
if (CollUtil.isEmpty(errorMsg)) {
insertExcelPost(excel,emp);
insertExcel(excel,emp);
errorMsg.add(CommonConstants.SAVE_SUCCESS);
temp.add(new ErrorMessage((long) (i + 2), errorMsg));
} else {
// 数据不合法
errorMessageList.add(new ErrorMessage((long) (i + 2), errorMsg));
temp.add(new ErrorMessage((long) (i + 2), errorMsg));
}
}
if (CollUtil.isNotEmpty(errorMessageList)) {
return R.failed(errorMessageList);
}
return R.ok();
temp.addAll(errorMsgMap.values());
return R.ok(temp);
}
/**
......@@ -173,43 +178,39 @@ public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, T
errorMessageList.stream().forEach(errorMessage -> errorMsgMap.put(errorMessage.getLineNum(),errorMessage));
}
// 个性化校验逻辑
List<TEmpEducation> list = this.list();
TEmployeeInfo emp;
TEmpEducation exist;
Set<String> errorMsg;
ErrorMessage errorMessage;
List<ErrorMessage> temp = new ArrayList<>();
// 执行数据插入操作 组装
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;
}
errorMsg = new HashSet<>();
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)) {
insertExcelPost(excel,emp);
updateExcel(excel);
errorMsg.add(CommonConstants.UPDATE_SUCCESS);
temp.add(new ErrorMessage((long) (i + 2), errorMsg));
} else {
// 数据不合法
errorMessageList.add(new ErrorMessage((long) (i + 2), errorMsg));
temp.add(new ErrorMessage((long) (i + 2), errorMsg));
}
}
if (CollUtil.isNotEmpty(errorMessageList)) {
return R.failed(errorMessageList);
}
return R.ok();
temp.addAll(errorMsgMap.values());
return R.ok(temp);
}
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) {
......@@ -233,7 +234,7 @@ public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, T
private void updateEducationOfEmp(TEmpEducation education) {
if (CommonConstants.ZERO_STRING.equals(education.getHighIdentification())){
EmpEducationUpdateVo updateVo = new EmpEducationUpdateVo();
EmpEducationUpdateVO updateVo = new EmpEducationUpdateVO();
BeanUtil.copyProperties(education, updateVo);
if (Integer.parseInt(education.getEducationName()) >= CommonConstants.FOUR_INT){
updateVo.setIsCollege(CommonConstants.ZERO_INT);
......@@ -247,7 +248,7 @@ public class TEmpEducationServiceImpl extends ServiceImpl<TEmpEducationMapper, T
/**
* 插入excel education
*/
private void insertExcelPost(EmpEducationExcelVO excel,TEmployeeInfo emp) {
private void insertExcel(EmpEducationExcelVO excel, TEmployeeInfo emp) {
TEmpEducation insert = new TEmpEducation();
BeanUtil.copyProperties(excel, insert);
insert.setDeleteFlag(CommonConstants.ZERO_STRING);
......
......@@ -79,6 +79,7 @@ public class TEmpFamilyServiceImpl extends ServiceImpl<TEmpFamilyMapper, TEmpFam
errorMessage = errorMsgMap.get(i+2);
if (Common.isNotNull(errorMessage)){
temp.add(errorMessage);
errorMsgMap.remove(i+2);
continue;
}
errorMsg = new HashSet<>();
......@@ -106,6 +107,7 @@ public class TEmpFamilyServiceImpl extends ServiceImpl<TEmpFamilyMapper, TEmpFam
temp.add(new ErrorMessage((long) (i + 2), errorMsg));
}
}
temp.addAll(errorMsgMap.values());
return R.ok(temp);
}
......
......@@ -90,6 +90,7 @@ public class TEmpProfessionalQualificationServiceImpl extends ServiceImpl<TEmpPr
errorMessage = errorMsgMap.get(i+2);
if (Common.isNotNull(errorMessage)){
temp.add(errorMessage);
errorMsgMap.remove(i+2);
continue;
}
errorMsg = new HashSet<>();
......@@ -117,6 +118,7 @@ public class TEmpProfessionalQualificationServiceImpl extends ServiceImpl<TEmpPr
temp.add(new ErrorMessage((long) (i + 2), errorMsg));
}
}
temp.addAll(errorMsgMap.values());
return R.ok(temp);
}
/**
......
......@@ -68,10 +68,15 @@ public class TEmpWorkRecordingServiceImpl extends ServiceImpl<TEmpWorkRecordingM
TEmployeeInfo emp;
TEmpWorkRecording exist;
Set<String> errorMsg;
ErrorMessage errorMessage;
List<ErrorMessage> temp = new ArrayList<>();
// 执行数据插入操作 组装
for (int i = 0; i < excelVOList.size(); i++) {
errorMessage = errorMsgMap.get(i+2);
// 已有验证报错直接下一个
if (Common.isNotNull(errorMsgMap.get(i+2))){
temp.add(errorMessage);
errorMsgMap.remove(i+2);
continue;
}
errorMsg = new HashSet<>();
......@@ -84,7 +89,6 @@ public class TEmpWorkRecordingServiceImpl extends ServiceImpl<TEmpWorkRecordingM
exist = baseMapper.selectOne(Wrappers.<TEmpWorkRecording>query().lambda()
.eq(TEmpWorkRecording::getEmpIdcard,excel.getEmpIdcard())
.eq(TEmpWorkRecording::getWorkUnit,excel.getWorkUnit())
.eq(TEmpWorkRecording::getWorkJob,excel.getWorkJob())
.eq(TEmpWorkRecording::getWorkDepart,excel.getWorkDepart())
.eq(TEmpWorkRecording::getDeleteFlag,CommonConstants.ZERO_STRING)
.last(CommonConstants.LAST_ONE_SQL));
......@@ -94,15 +98,15 @@ public class TEmpWorkRecordingServiceImpl extends ServiceImpl<TEmpWorkRecordingM
// 数据合法情况
if (CollUtil.isEmpty(errorMsg)) {
insertExcelPost(excel,emp);
errorMsg.add(CommonConstants.SAVE_SUCCESS);
temp.add(new ErrorMessage((long) (i + 2), errorMsg));
} else {
// 数据不合法
errorMessageList.add(new ErrorMessage((long) (i + 2), errorMsg));
temp.add(new ErrorMessage((long) (i + 2), errorMsg));
}
}
if (CollUtil.isNotEmpty(errorMessageList)) {
return R.failed(errorMessageList);
}
return R.ok();
temp.addAll(errorMsgMap.values());
return R.ok(temp);
}
@Override
......@@ -138,9 +142,6 @@ public class TEmpWorkRecordingServiceImpl extends ServiceImpl<TEmpWorkRecordingM
if (StrUtil.isNotBlank(recording.getWorkUnit())){
wrapper.eq(TEmpWorkRecording::getWorkUnit,recording.getWorkUnit());
}
if (StrUtil.isNotBlank(recording.getWorkJob())){
wrapper.eq(TEmpWorkRecording::getWorkJob,recording.getWorkJob());
}
if (StrUtil.isNotBlank(recording.getId())){
wrapper.ne(TEmpWorkRecording::getId,recording.getId());
}
......@@ -164,7 +165,6 @@ public class TEmpWorkRecordingServiceImpl extends ServiceImpl<TEmpWorkRecordingM
// 检查添加是否已经存在
boolean match = list.stream().anyMatch(info -> excel.getWorkDepart().equals(info.getWorkDepart())
&& excel.getWorkUnit().equals(info.getWorkUnit())
&& excel.getWorkJob().equals(info.getWorkJob())
&& excel.getEmpIdcard().equals(info.getEmpIdcard()));
if (match) {
......
......@@ -16,7 +16,6 @@
*/
package com.yifu.cloud.plus.v1.yifu.archives.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
......@@ -24,14 +23,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.plugin.excel.vo.ErrorMessage;
import com.yifu.cloud.plus.v1.check.entity.TCheckIdCard;
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.TEmployeeProject;
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.TEmployeeProjectService;
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.EmpEducationUpdateVO;
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.CommonConstants;
......@@ -669,7 +666,7 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
}
@Override
public void updateEducationOfEmp(EmpEducationUpdateVo education) {
public void updateEducationOfEmp(EmpEducationUpdateVO education) {
baseMapper.updateEducationOfEmp(education);
}
......
......@@ -231,9 +231,13 @@ public interface CommonConstants {
String SAVE_SUCCESS = "保存成功!";
String UPDATE_SUCCESS = "更新成功!";
String PARAM_IS_NOT_EMPTY = "参数不可为空";
// 是否
String IS_FALSE = "否";
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 com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ExcelAttribute;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.ValidityConstants;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import java.io.Serializable;
import java.lang.reflect.Field;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Author fxj
* @Date 2022/6/23
* @Description
* @Version 1.0
*/
@Data
@Slf4j
public class ExcelUtil <T> implements Serializable {
private Class<T> clazz;
/**
* 用于返回错误信息
*/
private List<ErrorMessage> errorInfo;
private HashMap<Integer, ErrorMessage> errorMessageHashMap;
public ExcelUtil(Class<T> clazz) {
this.clazz = clazz;
}
public void checkEntity(T data , Integer rowNum) {
//存储错误数据
Class<?> fieldType;
String error = "";
String c = null;
//临时存储单元格数据
String tempStr = "";
ErrorMessage errorTemp = null;
// 参数校验
Field[] fields = data.getClass().getDeclaredFields();
ExcelAttribute attr = null;
try{
for (Field field : fields) {
field.getAnnotation(ExcelAttribute.class);
// 单元格中的内容.
c = getStringValByObject(getFieldValueByName(attr.name(), data, DateUtil.ISO_EXPANDED_DATE_FORMAT));
if (c != null) {
c = c.trim();
}
//校验字段是否符合要求 返回错误信息
error = validateUtil(c, attr, rowNum);
if (null != error) {
errorMessageHashMap = initErrorMessage(errorMessageHashMap, new ErrorMessage(rowNum, error), errorTemp);
continue;
}
if (field == null) {
continue;
}
//单元格数据为空不需要处理了
if (!StringUtils.isNotBlank(c)) {
continue;
}
//如果是需要从字典表取值数据的话在这里处理即可
if (attr.isDataId()) {
if (Common.isNotNull(attr.dataType())) {
//非区域字段处理 TODO
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())){
tempStr = entry.getKey();
break;
}
}
/*if (Common.isNotNull(attr.parentField())){
tempStr = dicMap.get(attr.dataType() + "_" + c.trim() + "_" + getFieldValueByName(attr.parentField(), entity, DateUtil.ISO_EXPANDED_DATE_FORMAT));
}else {
tempStr = dicMap.get(attr.dataType() + "_" + c.trim());
}*/
} else {
if (attr.isArea()) {
//区域字段处理 TODO
/*if (!Common.isNotNull(attr.parentField())) {
tempStr = dicMap.get(c.trim() + "_0");
} else {
tempStr = dicMap.get(c.trim() + "_" + getFieldValueByName(attr.parentField(), entity, DateUtil.ISO_EXPANDED_DATE_FORMAT));
}*/
} else {
//直接按值去找数据 TODO
//tempStr = dicMap.get(c.trim());
}
}
if (!StringUtils.isNotBlank(tempStr)) {
if (attr.isOrgan()) {
errorMessageHashMap = initErrorMessage(errorMessageHashMap, new ErrorMessage(rowNum, "未找到:" + c + "的单位或结算主体数据,请确认存在结算主体权限"), errorTemp);
}
if (attr.isArea()) {
errorMessageHashMap = initErrorMessage(errorMessageHashMap, new ErrorMessage(rowNum, "未找到:" + c + "的区域数据"), errorTemp);
} else {
if (Common.isNotNull(attr.errorInfoImport())) {
errorMessageHashMap = initErrorMessage(errorMessageHashMap, new ErrorMessage(rowNum, "数据'" + c + "':" + attr.errorInfoImport()), errorTemp);
} else {
errorMessageHashMap = initErrorMessage(errorMessageHashMap, new ErrorMessage(rowNum, "未找到:" + c + "的字典数据"), errorTemp);
}
}
continue;
} else {
c = tempStr;
}
}
// 取得类型,并根据对象类型设置值.
fieldType = field.getType();
if (fieldType == null) {
continue;
}
if (String.class == fieldType) {
field.set(data, c);
} else if (BigDecimal.class == fieldType) {
c = c.indexOf('%') != -1 ? c.replace("%", "") : c;
field.set(data, BigDecimal.valueOf(Double.valueOf(c)));
} 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()));
} else if ((Integer.TYPE == fieldType) || (Integer.class == fieldType)) {
field.set(data, Integer.parseInt(c));
} else if ((Long.TYPE == fieldType) || (Long.class == fieldType)) {
field.set(data, Long.valueOf(c));
} else if ((Float.TYPE == fieldType) || (Float.class == fieldType)) {
field.set(data, Float.valueOf(c));
} else if ((Short.TYPE == fieldType) || (Short.class == fieldType)) {
field.set(data, Short.valueOf(c));
} else if ((Double.TYPE == fieldType) || (Double.class == fieldType)) {
field.set(data, Double.valueOf(c));
} else if (Character.TYPE == fieldType) {
if ((c != null) && (c.length() > 0)) {
field.set(data, Character.valueOf(c.charAt(0)));
}
} else if (LocalDateTime.class == fieldType && Common.isNotNull(c.trim())) {
String dc = c.trim().replace(CommonConstants.CENTER_SPLIT_LINE_STRING, "")
.replace(CommonConstants.SLASH_SPLIT_LINE_STRING, "");
try {
if (dc.length() > CommonConstants.EIGHT_INT) {
field.set(data, LocalDateTimeUtils.convertDateToLDT(DateUtil.stringToDate(dc, DateUtil.DATETIME_PATTERN_CONTAINS)));
}else {
field.set(data, LocalDateTimeUtils.convertDateToLDT(DateUtil.stringToDate(dc, DateUtil.ISO_DATE_FORMAT)));
}
} catch (Exception e) {
if (dc.length() > CommonConstants.EIGHT_INT) {
errorMessageHashMap = initErrorMessage(errorMessageHashMap,
new ErrorMessage(rowNum, attr.name() + ":" +
c.trim() + "应满足时间格式:" + DateUtil.DATETIME_PATTERN_SECOND), errorTemp);
continue;
} else {
errorMessageHashMap = initErrorMessage(errorMessageHashMap,
new ErrorMessage(rowNum, attr.name() + ":" +
c.trim() + "应满足时间格式:" + DateUtil.ISO_DATE_FORMAT), errorTemp);
continue;
}
}
} else if (LocalDate.class == fieldType && Common.isNotNull(c.trim())) {
try {
field.set(data, LocalDate.parse(c.trim().replace(CommonConstants.CENTER_SPLIT_LINE_STRING, ""), DateTimeFormatter.ofPattern(DateUtil.ISO_DATE_FORMAT)));
} catch (Exception e) {
errorMessageHashMap = initErrorMessage(errorMessageHashMap, new ErrorMessage(rowNum, attr.name() + ":" + c.trim() + "应满足时间格式:" + DateUtil.ISO_DATE_FORMAT), errorTemp);
continue;
}
}
}
}catch (Exception e){
errorMessageHashMap = initErrorMessage(errorMessageHashMap, new ErrorMessage(rowNum, attr.name() + ":" + c.trim() + "校验异常,请联系管理人员"), errorTemp);
}
this.setErrorMessageHashMap(errorMessageHashMap);
}
/**
* @param fieldName 字段名
* @param o 对象
* @return 字段值
* @MethodName : getFieldValueByName
* @Description : 根据字段名获取字段值
*/
public static Object getFieldValueByName(String fieldName, Object o, String dateFormat) {
Object value = null;
Field field = null;
if (o == null) {
return "";
}
field = getFieldByName(fieldName, o.getClass());
String type = getFieldType(fieldName, o.getClass());
if (field != null) {
field.setAccessible(true);
try {
if (null != type && type.equals("Date")) {
Date date = (Date) field.get(o);
return DateUtil.dateToString(date, dateFormat == null ? "yyyy-MM-dd" : dateFormat);
} else {
value = field.get(o);
}
} catch (IllegalAccessException e) {
e.printStackTrace();
}
} else {
log.info(o.getClass().getSimpleName() + "类不存在字段名 " + fieldName);
}
return value;
}
/**
* @param fieldName 字段名
* @param clazz 包含该字段的类
* @return 字段
* @MethodName : getFieldByName
* @Description : 根据字段名获取字段
*/
private static Field getFieldByName(String fieldName, Class<?> clazz) {
// 拿到本类的所有字段
Field[] selfFields = clazz.getDeclaredFields();
// 如果本类中存在该字段,则返回
for (Field field : selfFields) {
if (field.getName().equals(fieldName)) {
return field;
}
}
// 否则,查看父类中是否存在此字段,如果有则返回
Class<?> superClazz = clazz.getSuperclass();
if (superClazz != null && superClazz != Object.class) {
return getFieldByName(fieldName, superClazz);
}
// 如果本类和父类都没有,则返回空
return null;
}
/**
* @param fieldName 字段名
* @param clazz 包含该字段的类
* @return 字段
* @MethodName : getFieldType
* @Description : 根据字段名获取字段类型
*/
private static String getFieldType(String fieldName, Class<?> clazz) {
// 拿到本类的所有字段
Field[] selfFields = clazz.getDeclaredFields();
// 如果本类中存在该字段,则返回
for (Field field : selfFields) {
if (field.getName().equals(fieldName)) {
//如果type是类类型,则前面包含"class ",后面跟类名
String type = field.getGenericType().toString();
if (type.equals("class java.lang.String")) {
return "String";
} else if (type.equals("class java.lang.Integer")) {
return "Integer";
} else if (type.equals("class java.lang.Short")) {
return "Short";
} else if (type.equals("class java.lang.Double")) {
return "Double";
} else if (type.equals("class java.lang.Boolean")) {
return "Boolean";
} else if (type.equals("class java.util.Date")) {
return "Date";
} else {
return null;
}
}
}
// 否则,查看父类中是否存在此字段,如果有则返回
Class<?> superClazz = clazz.getSuperclass();
if (superClazz != null && superClazz != Object.class) {
return getFieldType(fieldName, superClazz);
}
// 如果本类和父类都没有,则返回空
return null;
}
/**
* 输出错误数据
*
* @param attr
* @param msg
* @param i
* @return
*/
private String errorInfo(ExcelAttribute attr, String msg, Integer i) {
return (Common.isEmpty(msg) ? (Common.isEmpty(attr.errorInfo()) ? "" : attr.errorInfo()) : (attr.name() + msg));
}
/**
* 正则匹配返回
*
* @param c
* @param attr
* @param pattern
* @return
* @Author fxj
* @Date 2019-08-06
**/
private boolean getMatchRes(String c, ExcelAttribute attr, String pattern) {
return !c.matches(Common.isEmpty(attr.pattern()) ? pattern : attr.pattern());
}
/**
* 实现各种校验方式的错误返回新
*
* @param c
* @param attr
* @param i
* @return
*/
private String validateUtil(String c, ExcelAttribute attr, int i) {
//非空校验
if (attr.isNotEmpty() && !Common.isNotNull(c)) {
return errorInfo(attr, "_字段不可为空", i);
}
if (Common.isNotNull(c)) {
//日期格式校验
if (attr.isDate()) {
DateUtil.stringToDate(c.trim(), attr.dateFormat());
}
//手机号码校验
if (attr.isPhone() && getMatchRes(c.trim(), attr, ValidityConstants.MOBILE_PATTERN)) {
return errorInfo(attr, "_手机号码有误", i);
}
//身份证校验
if (attr.isIdCard() && getMatchRes(c.trim(), attr, ValidityConstants.IDCARD_PATTERN)) {
return errorInfo(attr, "_身份证格式有误", i);
}
//邮箱验证
if (attr.isEmail() && getMatchRes(c.trim(), attr, ValidityConstants.EMAIL_PATTERN)) {
return errorInfo(attr, "_邮箱格式有误", i);
}
//integer 验证
if (attr.isInteger() && getMatchRes(c.trim(), attr, ValidityConstants.INTEGER_PATTERN)) {
return errorInfo(attr, "_整数格式有误", i);
}
//float、double 验证
if (attr.isFloat() && getMatchRes(c.trim(), attr, ValidityConstants.FLOAT_PATTERN)) {
return errorInfo(attr, "_数字格式有误", i);
}
if (attr.isDouble() && getMatchRes(c.trim(), attr, ValidityConstants.FLOAT_PATTERN)) {
return errorInfo(attr, "_数字格式有误", i);
}
//最大长度校验
if (attr.maxLength() > 0 && c.length() > attr.maxLength()) {
return errorInfo(attr, "_超出最大长度", i);
}
//最大值校验
if (attr.max() > 0) {
if (Common.isNumber(c)) {
if (attr.isDouble()){
if (Double.doubleToLongBits(Double.valueOf(c).doubleValue()) > Double.doubleToLongBits(attr.max())) {
return errorInfo(attr, "_超出最大值", i);
}
}else{
if (Float.valueOf(c).intValue() > attr.max()) {
return errorInfo(attr, "_超出最大值", i);
}
}
} else {
return errorInfo(attr, "_必须为数字且最多两位小数", i);
}
}
//最小值校验
if (attr.min() > 0) {
if (Common.isNumber(c)) {
if (attr.isFloat()){
if (Float.valueOf(c).compareTo(attr.max()) > CommonConstants.ZERO_INT) {
return errorInfo(attr, "_超出最大值", i);
}
}else{
if (Float.valueOf(c).intValue() < attr.min()) {
return errorInfo(attr, "_小于最小值", i);
}
}
} else {
return errorInfo(attr, "_必须为数字且最多两位小数", i);
}
}
}
return null;
}
/**
* 根据属性名获取属性值
*
* @param fieldName
* @param hashMap
* @return
*/
private static Object getFieldValueByName(String fieldName, HashMap hashMap) {
try {
return hashMap.get(fieldName);
} catch (Exception e) {
return null;
}
}
/**
* 按类型统一返回String内容
*
* @param param
* @return
*/
private static String getStringValByObject(Object param) {
if (null == param) {
return null;
} else if (param instanceof Integer) {
return Integer.toString(((Integer) param).intValue());
} else if (param instanceof String) {
return (String) param;
} else if (param instanceof Double) {
return Double.toString(((Double) param).doubleValue());
} else if (param instanceof Float) {
return Float.toString(((Float) param).floatValue());
} else if (param instanceof Long) {
return Long.toString(((Long) param).longValue());
} else if (param instanceof Boolean) {
return Boolean.toString(((Boolean) param).booleanValue());
} else if (param instanceof Date) {
return DateUtil.dateToString((Date) param);
} else if (param instanceof LocalDateTime) {
return LocalDateTimeUtils.formatTime((LocalDateTime) param, DateUtil.DATETIME_PATTERN_SECOND);
} else {
return param.toString();
}
}
private HashMap<Integer, ErrorMessage> initErrorMessage(HashMap<Integer, ErrorMessage> errorMessageHashMap, ErrorMessage errorMessage, ErrorMessage temp) {
if (null != errorMessageHashMap && null != errorMessage) {
temp = errorMessageHashMap.get(errorMessage.getLine());
if (null != temp) {
temp.setMessage(temp.getMessage() + CommonConstants.DOWN_LINE_STRING + errorMessage.getMessage());
errorMessageHashMap.put(temp.getLine(), temp);
} else {
errorMessageHashMap.put(errorMessage.getLine(), errorMessage);
}
}
return errorMessageHashMap;
}
}
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;
}
}
package com.yifu.cloud.plus.v1.yifu.common.core.util;
import cn.hutool.core.util.NumberUtil;
import com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants;
import java.text.SimpleDateFormat;
import java.time.*;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAdjusters;
import java.time.temporal.TemporalUnit;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import static java.time.format.DateTimeFormatter.ofPattern;
/**
* @author fang
* @Description LocalDateTime 工具类
*/
public class LocalDateTimeUtils {
private LocalDateTimeUtils() throws IllegalAccessException {
throw new IllegalAccessException("LocalDateTimeUtils class");
}
/**
* 日期时间格式yyyy-MM-dd HH:mm:ss
*/
public static final String DATE_TIME_PATTERN = "yyyy-MM-dd HH:mm:ss";
public static final String DATE_TIME_PATTERN_DEFAULT = "yyyy-MM-dd";
public static final String DATE_SHORT_PATTERN = "yyyyMMdd";
public static final String YEAR_MONTH_PATTERN = "yyyyMM";
//Date转换为LocalDateTime
public static LocalDateTime convertDateToLDT(Date date) {
return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
}
//LocalDateTime转换为Date
public static Date convertLDTToDate(LocalDateTime time) {
if (null != time){
return Date.from(time.atZone(ZoneId.systemDefault()).toInstant());
}
return null;
}
//获取指定日期的毫秒
public static Long getMilliByTime(LocalDateTime time) {
return time.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
}
//获取指定日期的秒
public static Long getSecondsByTime(LocalDateTime time) {
return time.atZone(ZoneId.systemDefault()).toInstant().getEpochSecond();
}
//获取指定时间的指定格式
public static String formatTime(LocalDateTime time, String pattern) {
return time.format(ofPattern(pattern));
}
public static LocalDateTime formatTime(String time, String pattern) {
Date date = DateUtil.stringToDate(time,pattern);
if (null != date){
Instant instant = date.toInstant();
ZoneId zone = ZoneId.systemDefault();
return LocalDateTime.ofInstant(instant,zone);
}
return null;
}
public static String formatDate(LocalDate date, String pattern) {
return date.format(ofPattern(pattern));
}
//获取当前时间的指定格式
public static String formatNow(String pattern) {
return formatTime(LocalDateTime.now(), pattern);
}
//日期加上一个数,根据field不同加不同值,field为ChronoUnit.*
public static LocalDateTime plus(LocalDateTime time, long number, TemporalUnit field) {
return time.plus(number, field);
}
//日期减去一个数,根据field不同减不同值,field参数为ChronoUnit.*
public static LocalDateTime minu(LocalDateTime time, long number, TemporalUnit field) {
return time.minus(number, field);
}
/**
* Date转LocalDateTime
*
* @param date
* Date对象
* @return
*/
public static LocalDateTime dateToLocalDateTime(Date date) {
return LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
}
public static String formatDateTime(LocalDateTime dateTime, String pattern) {
if (dateTime == null) {
return null;
}
if (pattern == null || pattern.isEmpty()) {
pattern = DATE_TIME_PATTERN;
}
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
return dateTime.format(formatter);
}
/**
* 获取两个日期的差 field参数为ChronoUnit.*
*
* @param startTime
* @param endTime
* @param field 单位(年月日时分秒)
* @return
*/
public static long betweenTwoTime(LocalDateTime startTime, LocalDateTime endTime, ChronoUnit field) {
Period period = Period.between(LocalDate.from(startTime), LocalDate.from(endTime));
if (field == ChronoUnit.YEARS) {
return period.getYears();
}
if (field == ChronoUnit.MONTHS) {
return (long)(period.getYears() * 12 + period.getMonths());
}
return field.between(startTime, endTime);
}
/**
* 获取一天的开始时间,2017,7,22 00:00
* @Author fxj
* @Date 2020-10-14
* @param time
* @return
**/
public static LocalDateTime getDayStart(LocalDateTime time) {
return time.withHour(0)
.withMinute(0)
.withSecond(0)
.withNano(0);
}
/**
* 获取一天的结束时间,2017,7,22 23:59:59.999999999
* @Author fxj
* @Date 2020-10-14
* @param time
* @return
**/
public static LocalDateTime getDayEnd(LocalDateTime time) {
return time.withHour(23)
.withMinute(59)
.withSecond(59)
.withNano(999999999);
}
public static List<String> getMonthFullDayStr(LocalDate startDate,LocalDate endDate, String pattern) {
List<String> dayStrList = new ArrayList<>();
DateTimeFormatter dateTimeFormatter = ofPattern(pattern);
LocalDate tempDate = startDate;
for(int i=0;endDate.isAfter(tempDate);i++){
tempDate = startDate.plusDays(i);
dayStrList.add(tempDate.format(dateTimeFormatter));
}
return dayStrList;
}
/**
* @param strDate
* @param pattern
* @Author: wangan
* @Date: 2019/8/22
* @Description: 校验日期合法性
* @return: boolean
**/
public static boolean isValidDate(String strDate, String pattern) {
SimpleDateFormat format = new SimpleDateFormat(pattern);
try {
// 设置lenient为false. 否则SimpleDateFormat会比较宽松地验证日期,比如2018-02-29会被接受,并转换成2018-03-01
format.setLenient(false);
format.parse(strDate);
} catch (Exception e) {
return false;
}
return true;
}
/**
* 获取time所在月的开始时刻 (1号0点0分0秒)
* @Author pwang
* @Date 2019-11-19 18:03
* @param time
* @return
**/
public static LocalDateTime firstdayOfMonth(LocalDateTime time){
return getDayStart(time).with(TemporalAdjusters.firstDayOfMonth());
}
/**
* 获取time所在月的结束时刻 (最后一天23点59分59秒)
* @Author pwang
* @Date 2019-11-19 18:03
* @param time
* @return
**/
public static LocalDateTime lastDayOfMonth(LocalDateTime time){
return getDayEnd(time).with(TemporalAdjusters.lastDayOfMonth());
}
/**
* 获取time所在年的开始时刻 (1月1号0点0分0秒)
* @Author pwang
* @Date 2019-11-19 18:03
* @param time
* @return
**/
public static LocalDateTime firstdayOfYear(LocalDateTime time){
return getDayStart(time).with(TemporalAdjusters.firstDayOfYear());
}
/**
* 获取time所在年的结束时刻 (最后一天23点59分59秒)
* @Author pwang
* @Date 2019-11-19 18:03
* @param time
* @return
**/
public static LocalDateTime lastDayOfYear(LocalDateTime time){
return getDayEnd(time).with(TemporalAdjusters.lastDayOfYear());
}
/**
* 月份差
* @param startMonth
* @param endMonth
* @param format (y,M,d元素不可少,否则报错。如yyyyMM少了dd会报错)
* @return
*/
public static Integer getBeginOfMonth(String startMonth,String endMonth,String format){
LocalDate bef = LocalDate.parse(startMonth, ofPattern(format));
LocalDate aft = LocalDate.parse(endMonth, ofPattern(format));
return getBeginOfMonth(bef,aft);
}
/**
* 月份差
* @param startDate
* @param endDate
* @return
*/
public static Integer getBeginOfMonth(LocalDate startDate,LocalDate endDate){
Period periodTime = Period.between(startDate, endDate);
int month = periodTime.getMonths() ;
int years = periodTime.getYears();
return Math.abs(month + years * 12);
}
public static LocalDateTime getNextMonthLocalDateTime(){
try {
Date date =DateUtil.getCurrentDateTime();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.MONTH,1);
calendar.set(Calendar.DATE, calendar.getActualMaximum(Calendar.DATE));
//获取最终的时间
Date time = calendar.getTime();
return time.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
}catch (Exception e){
return null;
}
}
/**
* 获取当天凌晨时间
* @Author pwang
* @Date 2020-09-10 17:59
* @param time
* @return
**/
public static LocalDateTime getThatDayStartTime(LocalDateTime time){
return LocalDateTime.of(time.toLocalDate(), LocalTime.MIN);
}
/**
* 获取当天凌晨时间
* @Author pwang
* @Date 2020-09-10 18:00
* @param day
* @return
**/
public static LocalDateTime getThatDayStartTime(LocalDate day){
return LocalDateTime.of(day, LocalTime.MIN);
}
/**
* 获取今天天凌晨时间
* @Author pwang
* @Date 2020-09-10 18:00
* @param
* @return
**/
public static LocalDateTime getToDayStartTime(){
return getThatDayStartTime(LocalDate.now());
}
/**
* 年月拼接成时间 如 202001 转成 LocalDateTime 2020-01-01
* @Author fxj
* @Date 2020-12-30
* @param yearMonth 202001
* @param patternDefault
* @return
**/
public static LocalDateTime dateOfYearAndMonth(String yearMonth, String patternDefault) {
if (Common.isEmpty(patternDefault)){
patternDefault = DATE_SHORT_PATTERN;
}
if (Common.isEmpty(yearMonth) ||
yearMonth.length() != CommonConstants.SIX_INT ||
!NumberUtil.isInteger(yearMonth)){
return null;
}
return convertDateToLDT(DateUtil.stringToDate(yearMonth+"01",patternDefault));
}
/**
*计算两个时间点的分钟差
* @Author chenyuxi
* @param dt1 第一个时间点
* @param dt2 第二个时间点
*/
public static int dateDiffByMinute(LocalDateTime dt1, LocalDateTime dt2) {
return dateDiff(dt1, dt2, 60);
}
/**
*计算两个时间点的小时差
* @Author chenyuxi
* @param dt1 第一个时间点
* @param dt2 第二个时间点
*/
public static int dateDiffByHour(LocalDateTime dt1, LocalDateTime dt2) {
return dateDiff(dt1, dt2, 60*60);
}
/**
*计算两个时间点的天数差
* @Author chenyuxi
* @param dt1 第一个时间点
* @param dt2 第二个时间点
*/
public static int dateDiffByDay(LocalDateTime dt1, LocalDateTime dt2) {
return dateDiff(dt1, dt2, 60*60*24);
}
/**
*计算两个时间点的时间差
* @Author chenyuxi
* @Date 2021-02-25 18:47
* @param dt1 第一个时间点
* @param dt2 第二个时间点
* @return int,即指定要计算的时间差
*/
private static int dateDiff(LocalDateTime dt1, LocalDateTime dt2, int timeNum) {
//获取第一个时间点的时间戳对应的秒数
long t1 = dt1.toEpochSecond(ZoneOffset.ofHours(0));
//获取第一个时间点在是1970年1月1日后的第几天
long minute1 = t1 /(timeNum);
//获取第二个时间点的时间戳对应的秒数
long t2 = dt2.toEpochSecond(ZoneOffset.ofHours(0));
//获取第二个时间点在是1970年1月1日后的第几天
long minute2 = t2/(timeNum);
//返回两个时间点的分钟差
return (int)(minute2 - minute1);
}
/**
* @param dateTime
* @param mnt
* @Description: 时间加减月份
* @Author: hgw
* @Date: 2021/12/20 17:00
* @return: java.lang.String
**/
public static String addMonthByDate(LocalDateTime dateTime, int mnt) {
if (dateTime == null) {
return null;
}
dateTime = dateTime.plusMonths(mnt);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(YEAR_MONTH_PATTERN);
return dateTime.format(formatter);
}
}
......@@ -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.util.SpringContextHolder,\
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;
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.R;
import com.yifu.cloud.plus.v1.yifu.common.core.util.RedisUtil;
import com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
......
com.yifu.cloud.plus.v1.yifu.common.feign.YifuFeignAutoConfiguration=\
com.yifu.cloud.plus.v1.yifu.admin.api.feign.RemoteDictService,\
com.yifu.cloud.plus.v1.yifu.admin.api.feign.RemoteDeptService,\
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
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.yifu.cloud.plus.v1.yifu.common.core.config.JacksonConfiguration
\ No newline at end of file
......@@ -79,5 +79,7 @@ public interface SysDictItemService extends IService<SysDictItem> {
**/
R<Map<String, Map<String, String>>> getDictToValue();
Map<String, Object> getAllDictItemSub();
void clearDictItemCache();
}
......@@ -168,11 +168,15 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi
@CacheEvict(value = CacheConstants.DICT_ITEM_DETAILS, key = CacheConstants.DICT_ITEM_DETAILS)
@Override
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()
.eq(SysDictItem::getDelFlag,CommonConstants.ZERO_STRING));
Map<String, Object> resultMap = new HashMap<>();
extracted(allList, resultMap);
return R.ok(resultMap);
return resultMap;
}
/**
* @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 {
#if($column.columnName == $pk.columnName)
@TableId(type = IdType.ASSIGN_ID)
#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)
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